3Dmodels are those model which has 3 measurements length, width, and depth. These models give an incredible user experience when utilized for different purposes. What’s more, adding such a sort of perception to your application will be extremely useful for the user, helping your application develop and attract an enormous crowd.
In this article, we will 3D Models In Flutter. We will implement a 3d model demo program and show 3D models in the glTF and GLB formats using themodel_viewer_plus package in your Flutter applications.
A Flutter widget for delivering interactive 3D models in the glTF and GLB designs. The widget inserts Google’s <model-viewer> web part in a WebView. The 3D model shows a 3D picture, and the user ought to turn toward any path for the watcher.
Demo Module :
This demo video shows how to create a 3d model in a flutter. It shows how the 3d model will work using themodel_viewer_plus package in your Flutter applications. It shows 3D models in the glTF and GLB format and rotates 360° degrees by mouse, hand touch, and auto-rotate. It will be shown on your device.
Features:
There are features of the model viewer plus:
> It renders glTF and GLB models. (Also, USDZ models on iOS 12+.)
> It Supports animated models with a configurable auto-play setting.
> It optionally supports launching the model into an AR viewer.
> It optionally auto-rotates the model with a configurable delay.
> It supports a configurable background color for the widget.
Parameters:
There are some parameters of the model viewer are:
> src: This parameter is used for the URL or path to the 3D model. This parameter is required. Only glTF/GLB models are supported.
> alt: This parameter is utilized to design the model with custom content that will portray the model to watchers who utilize a screen reader or, in any case, rely upon an extra semantic setting to comprehend what they are seeing.
> autoRotateDelay: This parameter sets the deferral before auto-revolution starts. The configuration of the worth is a number in milliseconds. The default is 3000.
> iosSrc: This parameter is used to the URL to a USDZ model, which will be used on supported iOS 12+ devices via AR Quick Look.
> arScale: This parameter is utilized to control the scaling conduct in AR mode in Scene Viewer. Set to “fixed” to incapacitate the model’s scaling, which sets it to be at 100% scale consistently. Defaults to “auto,” which permits the model to be resized.
Step 4: Run flutter packages get in the root directory of your app.
Step 5: AndroidManifest.xml (Android 9+ only)
android/app/src/main/AndroidManifest.xml
To utilize this widget on Android 9+ devices, your application should be allowed to make an HTTP association with http://localhost:XXXXX. Android 9 (API level 28) changed the default forandroid:usesCleartextTrafficfrom true to false.
To enable the widget on iOS, add a boolean property named “io.flutter.embedded_views_preview” to your app’s ios/Runner/Info.plist file with the value “YES”.
You need to implement it in your code respectively:
Create a new dart file called demo_view.dart inside the lib folder.
In the body, we will add ModelViewer(). Inside, we will add a backgroundColor for the model viewer; src means the user adds URL and assets only glTF/GLB models are supported.
ModelViewer(
backgroundColor: Colors.teal[50]!,
src: 'assets/table_soccer.glb',
alt: "A 3D model of an table soccer",
autoPlay: true,
autoRotate: true,
cameraControls: true,
),
We will add alt means configures the model with custom text that will describe the model to viewers who use a screen reader; autoplay means if this is true and a model has animations, an animation will automatically begin to play when this attribute is set. The default is false. We will add autoRotate means it enables the auto-rotation of the model. We will add cameraControls which enables controls via mouse/touch when in flat view.
When we run the application, we ought to get the screen’s output like the underneath screen capture.
Code File:
import 'package:flutter/material.dart';
import 'package:model_viewer_plus/model_viewer_plus.dart';
class DemoView extends StatefulWidget {
const DemoView({super.key});
@override
_DemoViewState createState() => _DemoViewState();
}
class _DemoViewState extends State<DemoView> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Flutter 3D Model Viewer Demo"),
automaticallyImplyLeading: false,
backgroundColor: Colors.black,
centerTitle: true,
),
body: ModelViewer(
backgroundColor: Colors.teal[50]!,
src: 'assets/table_soccer.glb',
alt: "A 3D model of an table soccer",
autoPlay: true,
autoRotate: true,
cameraControls: true,
),
);
}
}
Conclusion:
In the article, I have explained the 3D Model basic structure in a flutter; you can modify this code according to your choice. This was a small introduction to3D Model On User Interaction from my side, and it’s working using Flutter.
I hope this blog will provide you with sufficient information to try upthe 3D Model in your flutter projects. We will show you what the Introduction is?. Some model viewer plus features, and parameters, make a demo program for working 3D Models and show 3D models in the glTF and GLB format and rotate 360° degrees by mouse, hand touch, and auto-rotate using themodel_viewer_plus package in your flutter applications. So please try it.
❤ ❤ Thanks for reading this article ❤❤
If I got something wrong? Let me know in the comments. I would love to improve.
Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.
Feel free to connect with us: And read more articles fromFlutterDevs.com.
FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a Flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, and LinkedIn for any flutter-related queries.
Wewelcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.
This blog will explorethe Supabase Database with Flutter: Building Powerful Apps with Real-Time Functionality. We will also implement a demo program, and learn how to integrate Supabase in your Flutter applications.
Flutter has emerged as a popular choice for building cross-platform mobile applications due to its ease of use and impressive performance. When it comes to integrating a robust backend database into your Flutter app, Supabase offers an excellent solution. In this blog, we’ll explore Supabase and how you can leverage its features to power your Flutter app with a powerful and scalable database. Let’s dive in!
What is Supabase?
In today’s fast-paced world, building powerful and responsive applications is essential to meet the demands of users. And when it comes to developing data-driven applications with real-time functionality, having a robust and scalable backend is crucial. Enter Supabase, an open-source Backend-as-a-Service (BaaS) solution that combines the best of Firebase and traditional databases. It is built on top of PostgreSQL and extends its capabilities with additional features like real-time and Authentication. With Supabase, you get a scalable, secure, and real-time database that can seamlessly integrate with your Flutter app.
In this blog post, we will explore the integration of Supabase with Flutter, allowing you to leverage its real-time database and authentication features to build dynamic and interactive apps. We will delve into the key concepts of Supabase and demonstrate how it empowers developers to create applications that scale effortlessly while maintaining data integrity and security.
Whether you’re a seasoned Flutter developer or just starting your journey, this guide will provide you with a comprehensive understanding of Supabase and its integration with Flutter. By the end, you’ll be equipped with the knowledge to develop powerful, real-time applications backed by a reliable and scalable database solution.
Features:-
Managing Data with Supabase
Supabase simplifies data management in your Flutter app. You can use the SupabaseClient class to perform queries, inserts, updates, and deletions. Additionally, you can leverage the real-time functionality to subscribe to changes in the database, ensuring that your app’s data remains up-to-date in real time.
Securing Your Flutter App with Supabase Authentication
User authentication is crucial for most applications. Supabase offers built-in authentication features, allowing you to authenticate users through various methods like email/password, social logins (Google, Facebook, etc.), and more. We’ll guide you through implementing secure user authentication in your Flutter app using Supabase.
Optimizing Performance with Supabase Indexes
Indexes play a vital role in optimizing database performance. Supabase provides the ability to create indexes on frequently queried columns, significantly improving query response times. We’ll explore how to identify the right columns to index and implement them in your Supabase database.
Getting Started with Supabase:
To begin using Supabase in your Flutter app, you need to set up a Supabase project. This involves signing up for an account in the dashboard and creating a new project here.
Once your project is set up, you will receive a URL and API key, essential for accessing the Supabase database.
To get the URL and API key, follow the below guidelines:
After successfully signing in and creating your project, go to the Home option.
2. Navigate to the Project API section below, where you’ll discover the URL and API key of your Supabase project.
Integration of Supabase into Flutter:
With your Supabase project ready, it’s time to integrate it into your Flutter app. You can do this using the Supabase Dart package, which provides a set of APIs to interact with the Supabase backend. Through these APIs, you can perform CRUD operations, manage user authentication, and subscribe to real-time data updates. Follow the below steps to do so:
—Import the latest version of the supabase_flutter package in pubspec.yaml file of your Flutter project.
dependencies: supabase_flutter: ^1.10.9
— Initialise Supabase in the Flutter project by providing the Supabase project’s URL and API key to establish the connection.
Now, for a successful login, the email you used during sign-up needs to be verified. After verifying the email, I returned to the app.
Conclusion:-
In this blog, we comprehensively understood the Supabase database and its powerful functionalities. Now, it’s time to apply this knowledge to your projects and delve deeper into the possibilities it offers. Happy exploring!
❤ ❤ Thanks for reading this article ❤❤
If I got something wrong? Let me know in the comments. I would love to improve.
Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.
Feel free to connect with us: And read more articles fromFlutterDevs.com.
FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a Flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! For any flutter-related queries, you can connect with us on Facebook, GitHub, Twitter, and LinkedIn.
Wewelcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.
Today marks the arrival of Flutter 3.19, a milestone release packed with exciting new features and enhancements. Among the highlights is the introducing of a new Dart SDK for Gemini, empowering developers with enhanced performance and capabilities. Additionally, developers now have access to a versatile widget designed to offer precise control over widget animations, alongside rendering improvements with updates to Impeller.
Flutter 3.19 doesn’t stop there; it also introduces essential tooling for implementing deep links, streamlining the development process. Moreover, this release extends support to Windows Arm64, broadening the range of platforms developers can target with their Flutter applications.
The Flutter community’s dedication is evident in this release, with an impressive 1429 pull requests merged, contributed by 168 community members. Notably, 43 individuals made their inaugural contributions to the Flutter codebase, underscoring the vibrancy and inclusivity of the Flutter community.
Keep reading to discover the latest additions and improvements that define this remarkable release!
What’s new we got?
AI Integration: —
Gemini Google AI Dart SDK (beta) — Beta release of Google AI Dart SDK integrates generative AI into Dart/Flutter apps via Gemini models. Explore google_generative_ai package on pub.dev for quickstarts & tutorials.
Framework: —
Scrolling improvements — In the latest Flutter update, scrolling behavior has been enhanced for smoother navigation. MultiTouchDragStrategy.latestPointernow offers consistent scrolling regardless of the number of fingers used. Bugs inSingleChildScrollViewandReorderableList have been fixed, addressing crashes and unexpected behavior. Two-dimensional scrolling has been refined, ensuring interruptions during scroll actions. Additionally, TableView in the two_dimensional_scrollables package has received updates, including enhanced features like merged cells and compatibility with the 2D foundation improvements.
=AnimationStyle — Flutter introduces the AnimationStylewidget, empowering developers to customize animation behavior in MaterialApp, ExpansionTile, andPopupMenuButton, including curve and duration overrides.
SegmentedButton.styleFrom — Introduction of styleFrom method for SegmentedButton, facilitating easy creation of ButtonStyle for shared usage or theme configuration.
Adaptive Switch —The adaptive component seamlessly blends into macOS/iOS or adopts Material Design elsewhere. Consistent API across platforms, independent of Cupertino library. See adaptive switch PR& live example on Switch.adaptive constructor API page.
Increased access to text widget state — Support for MaterialStatesControllerinTextFieldandTextFormField facilitates listening to MaterialStatechanges.
Engine: —
Impeller progress —Flutter 3.16’s Impeller on Vulkan for Android covers 77% devices, now with OpenGL feature parity including MSAA. Developers urged to upgrade, report issues for refinement. Detailed device and Android version feedback crucial. Vulkan offers enhanced debugging but with added runtime overhead. Performance focus post-fidelity, with Vulkan subpasses for blend modes, CPU utilization reduction via Stencil-then-cover, and Gaussian blurring improvements for iOS. Read more.
API improvements: —
Glyph Information —New methods, getClosestGlyphInfoForOffset and getGlyphInfoAt, are added to dart:ui’s Paragraphobject, introducing the GlyphInfotype. Refer to the documentation for details on GlyphInfo.
GPU tracing — Flutter engine now provides GPU frame timing on Impeller for iOS/macOS/Simulator and Vulkan-enabled Android devices in debug/profile builds, accessible in DevTools under “GPUTracer”. Impeller’s GPU tracing requires a flag in AndroidManifest.xml due to potential misreporting by non-Vulkan Android devices regarding GPU timing support.
Specialization constants — Adding support for specialization constants to Impeller reduced the Flutter engine’s uncompressed binary size by nearly 350KB.
and others.
Android: —
Deeplinking web validator — Developers find deep linking challenging and error-prone. To address this, 3.19 has released an early version of the Flutter deep link validator. It currently supports web checks on Android, validating assetlinks.jsonsetup. Simply import your Flutter project into DevTools to verify your configuration. Future updates will include web check on iOS and app check on both platforms, aiming to simplify deep linking implementation. Read more.
Support for Share. invoke — In this release, the default Share button on Android text fields and views has been added to ensure all default context menu buttons are available on each platform.
Native assets feature — Flutter now enables interoperability with functions from other languages via FFI calls through Native assets on Android, advancing support for Native assets.
Texture Layer Hybrid Composition (TLHC) mode —Flutter 3.19 improves TLHC mode for Google Maps and text input magnifier, enhancing app performance.
Custom system-wide text selection toolbar buttons — Flutter’s TextField selection menu integrates custom text selection menu items from Android apps, enhancing user experience.
iOS: —
Flutter iOS native fonts — Flutter text now appears more compact and native on iOS, adhering to Apple design guidelines. Smaller fonts are now spaced out for readability, while larger fonts are compact to save space. Previously, Flutter incorrectly used the spaced-out font for all text sizes. For example, check here.
DevTools: —
DevTools updates — New DevTools release highlights:
Android deeplinks validation feature added.
Enhance Tracing menu now tracks platform channel activity, which is beneficial for plugin-based apps.
Performance and CPU profiler screens are accessible without a connected app, allowing reloading of saved data.
The Flutter Sidebar in VS Code enables new platforms and offers the option to open DevTools in the external browser window.
Desktop: —
Windows Arm64 support — Flutter on Windows introduces initial Arm64 support, promising enhanced performance for apps on Windows Arm64 devices. Development progress is tracked on GitHub issue #62597, offering Flutter developers broader optimization possibilities.
Conclusion:-
We’ve comprehensively explored nearly all the new features introduced in Flutter 3.19 in this blog. We hope you found it insightful and enjoyable. Take the opportunity to delve into these new features and explore their practical applications.
❤ ❤ Thanks for reading this article ❤❤
If I got something wrong? Let me know in the comments. I would love to improve.
Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.
Feel free to connect with us: And read more articles fromFlutterDevs.com.
FlutterDevs team of Flutter developers to build high-quality and functionally rich apps. Hire a Flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! For any flutter-related queries, you can connect with us on Facebook, GitHub, Twitter, and LinkedIn.
Wewelcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.
This blog will explore the CI/CD with Bitbucket In Flutter. We perceive how to execute a demo program. We will show you how to use aCI/CD with Bitbucket in your Flutter applications.
Why do we need to use CI/CD as an extra step in our development, and configure DevOps-like things in our development routine?
Life is full of challenges and we handle them very efficiently. There are some situations when we don’t know what to do, which can be avoided only by adopting automation in the system. Let’s assume you have worked hard with entire focus throughout the week and then finished your work to meet your deadline. Now you want to have a party with your friends and at the party, you get a call that the build you shared with the client is not installed on his device and as you are smart you realize that you forgot to clean the project before making a build.
Will you leave the party and get back to your laptop to check it or you call your subordinates to make a build with full cleaning this was the sole purpose of your party, and you don’t want to disappoint your client. Situations can vary but actual things come out in actual scenarios, not virtual ones.
Then your friend tells you that he has set up the CI/CD in his project on bitbucket or git-like VCS in which the build is tested before every push with full clean passing of all the lint warnings and test cases and he doesn’t need to even share any build as the build gets auto uploaded to the desired place by DevOps engine like Jenkins.
Now you know why CI/CD is important. There are other benefits also like if you have a large team of developers and some are lazy ones to test their code before committing to the cloud, then your army of test cases and intelligence of CI/CD will handle them for you, you can have party!!!.
What is CI/CD?
You know about it already though we can assume it is a system that continuously tests and deploys the code before and after the situation you want as a set of tools to automate our code integration, testing, and deployment.
Bitbucket, Git, Gitlab all offers it, Also, there is Jenkins, CI which does the job very well and uploads your artifacts on the Play Store, app center, app store, and other distribution channels.
How can we do it?
The process seems to be tough as everything new for us looks tough and our mind finds excuses to avoid it.
So don’t think too much and stay with me, you will have a lot of it in the next 5 mins.
Ingredients:
Bitbucket account, a flutter project and that’s it.
Steps:
To be concise I will be doing it fast but let me know if you need any further explanation so I can write a detailed blog on then, Let’s start…
> Create a repository on bitbucket and clone your flutter code on it.
> Create a .yaml file and open it in edit mode.
> Put this code in the file and save it.
image: mobiledevops/flutter-sdk-image:3.10.3 pipelines: branches: master: - step: script: - echo "This script runs only on commit to the main branch." - flutter pub get - flutter build apk --release artifacts: - build/app/outputs/apk/release/* feature/*: - step: script: - echo "This script runs only on commit to the main branch." - flutter pub get - flutter build apk --release artifacts: - build/app/outputs/apk/release/*
> It will run and build the apk from the code and upload it in artifacts.
> You can download it from the artifacts section.
NOTE: Keep the indentation the same as it will create issues in compiling.
Now, the Fast and Furious one is done here, and the crazy and curious ones are welcome to understand the meaning of the steps we have taken.
The 3rd step was all the magic so we will see it in slow motion to have it.
1. We defined a docket image to pull for executing the flutter commands.
2. Next we declare the branch or we can have default if you want all branches to have it.
3. Then steps come and we start writing the script
4. Echo are the messages that we want when a step gets executed.
5. Flutter Clean will clean the project which is recommended before making any apk.
6. Flutter build apk — release will make the apk in a release format that is very efficient and not have any dev dependencies and is compact.
7. Artifact gives the path to find your apk so that it can be uploaded to download later from the server.
8. we can add more steps to it like testing and analyzing but those will be covered in the next blog.
Conclusion:
In today’s life, a lot of things are going automated and so TDD(Test-driven development), CI/CD, and other DevOps tools are replacing manpower to remove shallow works in the systems. So learning these concepts and technologies will surely add some value to your database.
The next blog will be on Jenkins with App Center. Till then Keep Coding, Deep Coding.
❤ ❤ Thanks for reading this article ❤❤
If I need to correct something? Let me know in the comments. I would love to improve.
Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.
Feel free to connect with us: And read more articles fromFlutterDevs.com.
FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a Flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! For any flutter-related queries, you can connect with us on Facebook, GitHub, Twitter, and LinkedIn.
Wewelcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.
In this article, we will explore the Segmented State Pattern. We will also implement a demo program and learn how to implement it in your Flutter applications.
First of all, I would like to introduce you to Segmented State Pattern.
Segmented State Pattern is a state management pattern in Flutter that uses Streams or ValueNotifiers. The Triple package is a simple package that uses this pattern. State management is a critical aspect of building complex and interactive applications in Flutter. It helps you:
Control and update the data that your UI displays
Know about your application, where the user is in the app, what they are doing, and what data they are inputting
Align and integrate the core business logic inside the application with servers and databases
Ensure that the different parts of the application are working together predictably and consistently.
Implementation:
Let’s see how to Implement the Segmented State Pattern (Triple Pattern ).
First Add the dependencies in pubsec.yaml file
dependencies: flutter_triple: ^3.0.0
Alright, now we will work on our store part for this. First of all, we will create a new file and call it counter_store.dart
When we run the application, we ought to get the screen’s output like the underneath screen capture.
Output
Conclusion:
In triple state management, onLoad Listener is an event that occurs when an object has been loaded. It’s often used within the body widget.
errorBuilder is a function that is executed when the task’s status is set to Error. It returns a widget that is called when the state is BaseErrorState.
loadingBuilder is a property that is a focused circular progress indicator until updating the counter value view on the screen. It allows you to customize the widget that’s displayed while the counter value increase action is performed
❤ ❤ Thanks for reading this article ❤❤
If I got something wrong? Let me know in the comments. I would love to improve.
Clap 👏 If this article helps you.
GitHub Link:
You can check out Segmented State Pattern on GitHub. We hope you enjoyed this tutorial
Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.
Feel free to connect with us: And read more articles fromFlutterDevs.com.
FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a Flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! For any flutter-related queries, you can connect with us on Facebook, GitHub, Twitter, and LinkedIn.
Wewelcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.
In this article, we will explore Chart Export in Different Formats. We will also implement a demo program and learn how to implement it in your Flutter applications.
A Flutter Charts library which includes data visualization widgets such as bar charts, circular charts, and line charts, to create real-time, interactive, high-performance, animated charts.
To render a Flutter chart utilizing JSON data, you can utilize the deserialization idea. This includes changing the JSON data over completely to a Dart list object. You can then utilize the deserialized list object as chart data for a Flutter Cartesian chart.
Here are some ways to export charts in Flutter:
> SfCartesianChart: Exports Cartesian charts as PNG images or PDF documents
> Syncfusion’s Flutter DataGrid export library: Exports Flutter DataGrids to Excel and PDF formats
Implementation:
Let’s see how to Implement Chart Rendering in Different Formats.
First Add the dependencies in pubsec.yaml file
dependencies: syncfusion_flutter_charts: ^22.2.8
Alright, now we will work on further implementation for:
We will create a new class BarChartView() class. In this class, we will add barChartData is equal to the array bracket. In the body part, we will add a column widget. In this widget, we will add the BarChartViewWidget() method.
In this method, we will add maximumPoint, intervalPoint, key, chartData, and toolTip. Now we will add three custom buttons PNG Image, PDF File, and Excel (xls) for the download bar chart in these formats.
When we run the application, we ought to get the screen’s output like the underneath screen Capture.
Bar Chart Output
Line Chart:
We will create a new class LineChartView() class. In this class, we will add lineChartData is equal to the array bracket. In the body part, we will add a column widget. In this widget, we will add the LineChartViewWidget() method.
In this method, we will add maximumPoint, intervalPoint, key, linechartData, and toolTip. Same as above we will add three custom buttons PNG Image, PDF File, and Excel (xls) for the download line chart in these formats.
When we run the application, we ought to get the screen’s output like the underneath screen Capture.
Line Chart Output
Pie Chart:
We will create a new class PieChartView() class. In this class, we will add pieChartData is equal to the array bracket. In the body part, we will add a column widget. In this widget, we will add the RepaintBoundary() method.
In this method, we will add a key and a child. In child was PieChartViewWidget(pieChartData: pieChartData) . Same as above we will add three custom buttons PNG Image, PDF File, and Excel (xls) for the download line chart in these formats.
When we run the application, we ought to get the screen’s output like the underneath screen Capture.
Pie Chart Output
Alright, now we will implement the download Functionality part:
> Export in PNG format
> Export in PDF format
> Export in Excel (.xls) format
Export in PNG Format:
We will create getRenderChartAsImage() method:
static Future<void> getRenderChartAsImage(
dynamic cartesianChartKey, bool isPieChart) async {
final Directory directory = await getApplicationSupportDirectory();
final String path = directory.path;
File file = File('$path/ChartImageOutput.png');
if (isPieChart) {
final RenderRepaintBoundary boundary =
cartesianChartKey.currentContext.findRenderObject();
final ui.Image image = await boundary.toImage();
final ByteData? byteData =
await image.toByteData(format: ui.ImageByteFormat.png);
final Uint8List? pngBytes = byteData?.buffer.asUint8List();
final Uint8List imageBytes = pngBytes!.buffer
.asUint8List(pngBytes.offsetInBytes, pngBytes.lengthInBytes);
await file.writeAsBytes(imageBytes, flush: true);
} else {
final ui.Image data =
await cartesianChartKey.currentState!.toImage(pixelRatio: 3.0);
final ByteData? bytes =
await data.toByteData(format: ui.ImageByteFormat.png);
final Uint8List imageBytes =
bytes!.buffer.asUint8List(bytes.offsetInBytes, bytes.lengthInBytes);
await file.writeAsBytes(imageBytes, flush: true);
}
OpenFile.open('$path/ChartImageOutput.png');
}
When we run the application, we ought to get the screen’s output like the underneath screen Capture.
Output
Export in PDF Format:
We will create getRenderPDF() method:
static Future<void> getRenderPDF(
dynamic cartesianChartKey, isPieChart) async {
final Directory directory = await getApplicationSupportDirectory();
final String path = directory.path;
File file = File('$path/ChartPdfOutput.pdf');
final List<int> imageBytes =
await _readImageData(cartesianChartKey, isPieChart);
final PdfBitmap bitmap = PdfBitmap(imageBytes);
final PdfDocument document = PdfDocument();
if (isPieChart) {
document.pageSettings.orientation = PdfPageOrientation.landscape;
}
document.pageSettings.size =
Size(bitmap.width.toDouble(), bitmap.height.toDouble());
final PdfPage page = document.pages.add();
final Size pageSize = page.getClientSize();
page.graphics.drawImage(
bitmap, Rect.fromLTWH(0, 0, pageSize.width, pageSize.height));
final List<int> bytes = document.saveSync();
document.dispose();
await file.writeAsBytes(bytes, flush: true);
OpenFile.open('$path/ChartPdfOutput.pdf');
}
We will create _readImageData() method:
static Future<List<int>> _readImageData(cartesianChartKey, isPieChart) async {
if (isPieChart) {
final RenderRepaintBoundary boundary =
cartesianChartKey.currentContext.findRenderObject();
final ui.Image image = await boundary.toImage();
final ByteData? byteData =
await image.toByteData(format: ui.ImageByteFormat.png);
final Uint8List? pngBytes = byteData?.buffer.asUint8List();
return pngBytes!.buffer
.asUint8List(pngBytes.offsetInBytes, pngBytes.lengthInBytes);
} else {
final ui.Image data =
await cartesianChartKey.currentState!.toImage(pixelRatio: 3.0);
final ByteData? bytes =
await data.toByteData(format: ui.ImageByteFormat.png);
return bytes!.buffer
.asUint8List(bytes.offsetInBytes, bytes.lengthInBytes);
}
}
When we run the application, we ought to get the screen’s output like the underneath screen Capture.
Output
Export in Excel (.xls) Format:
We will create getRenderChartAsExcel() method:
static Future<void> getRenderChartAsExcel(
List<dynamic> data, bool isLineChart) async {
final Directory directory = await getApplicationSupportDirectory();
final String path = directory.path;
final xcel.Workbook workbook = xcel.Workbook();
final xcel.Worksheet sheet = workbook.worksheets[0];
if (!isLineChart) {
sheet.getRangeByIndex(1, 1).setText("Sr.");
sheet.getRangeByIndex(1, 2).setText("Pending");
sheet.getRangeByIndex(1, 3).setText("Resolve-Requested");
sheet.getRangeByIndex(1, 4).setText("Resolve");
sheet.getRangeByIndex(1, 5).setText("Closed");
sheet.autoFitColumn(3);
for (var i = 0; i < data.length; i++) {
final item = data[i];
sheet.getRangeByIndex(i + 2, 1).setText(item.x);
sheet.getRangeByIndex(i + 2, 2).setText(item.y1.toString());
sheet.getRangeByIndex(i + 2, 3).setText(item.y2.toString());
sheet.getRangeByIndex(i + 2, 4).setText(item.y3.toString());
sheet.getRangeByIndex(i + 2, 5).setText(item.y4.toString());
}
final List<int> bytes = workbook.saveAsStream();
File file = File('$path/BarChartOutput.xlsx');
await file.writeAsBytes(bytes, flush: true);
await OpenFile.open('$path/BarChartOutput.xlsx');
AppLogger.log('data list :${file.lengthSync()}');
} else {
sheet.getRangeByIndex(1, 1).setText("Month");
sheet.getRangeByIndex(1, 2).setText(" Value ");
sheet.autoFitColumn(2);
for (var i = 0; i < data.length; i++) {
final item = data[i];
sheet.getRangeByIndex(i + 2, 1).setText(item.x);
sheet.getRangeByIndex(i + 2, 2).setText(item.y.toString());
}
final List<int> bytes = workbook.saveAsStream();
File file = File('$path/LineChartOutput.xlsx');
await file.writeAsBytes(bytes, flush: true);
await OpenFile.open('$path/LineChartOutput.xlsx');
}
workbook.dispose();
}
When we run the application, we ought to get the screen’s output like the underneath screen Capture.
Output
Conclusion:
In the article, I have explained the Chart Export in Different Formats In Flutter; you can modify this code according to your choice. This was a small introduction to the Chart Export in Different Formats In Flutter User Interaction from my side, and it’s working using Flutter.
I hope this blog will provide you with sufficient information on Trying Chart Export in Different Formats in your Flutter projects. We will show you what the Introduction is. Make a demo program for working on chart export in different formats in your Flutter applications. So please try it.
❤ ❤ Thanks for reading this article ❤❤
If I got something wrong? Let me know in the comments. I would love to improve.
Clap 👏 If this article helps you.
GitHub Link:
You can check out Implement Chart Export in Different Formats In Flutter on GitHub. We hope you enjoyed this tutorial
Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.
Feel free to connect with us: And read more articles fromFlutterDevs.com.
FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a Flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! For any flutter-related queries, you can connect with us on Facebook, GitHub, Twitter, and LinkedIn.
Wewelcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.
In this article, we will explorethe Implement Fish-ReduxStateManagement In Flutter. We perceive how to execute a demo program. We will show you how to work in your Flutter applications.
State management in Flutter refers to the techniques and tools used to manage and control the state (data and UI) of your Flutter application. Flutter applications often consist of complex UIs and dynamic data that can change over time.
Effective state management is crucial for creating responsive and maintainable apps. There are various approaches to state management in Flutter, and the choice of approach depends on the complexity of your application and your specific needs.
Introduction — Fish-Redux:-
Fish-Redux is a state management framework for building Flutter applications. It’s designed to help Flutter developers structure their applications in a way that makes code organization and maintenance easier, particularly for larger and more complex apps. Fish-Redux draws inspiration from concepts like Redux, a state management pattern used in web development, and applies them to the world of Flutter.
Key Concepts in Fish-Redux:-
State: In Fish-Redux, your application’s state is represented by plain Dart objects. These objects are typically immutable and describe the data that your application needs to function. State management in Fish-Redux revolves around creating, modifying, and sharing these state objects.
Action: Actions are the events or user interactions that trigger changes in your application’s state. Actions are dispatched to update the state. They carry information about what needs to change in the state.
Reducer: Reducers are responsible for taking the current state and an action and producing a new state. Reducers are pure functions that ensure the predictability and maintainability of the state management process.
Effect: Effects are side effects that can be triggered as a result of specific actions. They can be used for operations like making network requests, database access, or other asynchronous tasks. Fish-Redux provides a clean way to handle side effects.
Component: A component is a self-contained, reusable piece of the user interface. Each component in Fish-Redux consists of three parts: View, State, and Reducer. Components can be nested to build complex UI structures.
Page: A page in Fish-Redux is a logical collection of components. Pages help organize your app into meaningful sections. Each page has its state and can contain multiple components.
How to Use:-
Here are the basic steps to use Fish-Redux in your Flutter application:
Add Fish-Redux Dependency: Start by adding the Fish-Redux package as a dependency in your pubspec.yaml file:
dependencies: fish_redux: ^0.3.7 # Use the latest compatible version
Define the Application State: Create a Dart class that represents the state of your application. This class should extend Cloneable. Define the properties and initial values for your application’s state.
Example:
import 'package:fish_redux/fish_redux.dart';
class CounterState implements Cloneable<CounterState> {
int count;
@override
CounterState clone() {
return CounterState()..count = count;
}
}
Define Actions: Create action classes that describe the events or user interactions that can change the state. Actions should include all the necessary data for the change.
Create Reducers: Write reducer functions that take the current state and an action as input and produce a new state as output. Reducers should be pure functions.
Build Components: Create individual components for your UI. Each component includes a View (widget), State (describing the component’s local state), and Reducer (defining how to update the local state).
Define Pages: Organize your components into pages. Each page has its state and can contain multiple components.
Initialize the Fish-Redux Store: Create a Store that holds the global application state, reducers, and middleware. This is the central hub for state management.
Dispatch Actions: To update the state, dispatch actions to the store. The store will invoke the reducers to calculate the new state.
Build the UI: Use the components and pages to build the user interface. Components are generally built by buildView methods.
Handle Effects: For side effects like making API requests or accessing databases, use Effects to encapsulate the logic.
Fish-Redux provides a structured and organized way to manage the state of your Flutter application, making it easier to build and maintain large and complex apps.
Key Benefits:-
Centralized and Observable Data Management: Fish Redux simplifies data management by centralizing it through Redux. This means it retains all the advantages of Redux, and the framework even assembles the reducer automatically, making Redux usage more straightforward.
Component Division Management: Fish Redux divides views and data into components. By breaking down complex pages and data into smaller, independent modules, collaborative development within teams becomes much easier.
Isolation Between View, Effect, and Reducer: Each component is divided into three stateless and independent functions: View, Effect, and Reducer. Their statelessness makes them easy to write, debug, test, and maintain. This also allows for more flexibility in combining, reusing, and innovating.
Declarative Configuration Assemblies: Components and adapters are put together using free and declarative configuration, which includes defining a component’s view, reducer, effect, and its relationships with dependent child components.
Strong Scalability: The core framework focuses on its core responsibilities while providing flexibility for upper layers. While the framework itself doesn’t contain printed code, it allows observation of data flows and component changes through standard middleware. Additionally, mixins can be added to the component and adapter layers using Dart code, enhancing customizability and capabilities at the upper layer. The framework seamlessly communicates with other middlewares, such as those for automatic exposure and high availability, and allows for free assembly by the upper layer.
Small, Simple, and Complete: Fish Redux is incredibly lightweight, consisting of only around 1,000 lines of code. It’s user-friendly, requiring just a few small functions to set up before running. Despite its simplicity, Fish Redux provides a wide range of functionalities.
There’s a simple demo app below using fish-redux state management. Check the GitHub repo in the GitHub Link section.
This blog has provided a comprehensive understanding of Fish-Redux state management in Flutter applications. Now, you have the knowledge and tools to apply this powerful state management solution to your projects and explore the wide range of possibilities it offers. Enjoy your journey of exploration and development!
❤ ❤ Thanks for reading this article ❤❤
If I got something wrong? Let me know in the comments. I would love to improve.
Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.
Feel free to connect with us: And read more articles fromFlutterDevs.com.
FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a Flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! For any flutter-related queries, you can connect with us on Facebook, GitHub, Twitter, and LinkedIn.
Wewelcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.
Need expert help building your Flutter app?Talk to FlutterExperts for architecture, development, and consulting support.
Hello Everyone!!! Today we learn about PostgreSQL With Flutter In this article, we cover topics like how to set up PostgreSQL and also how we can use PostgreSQL With Flutter.
PostgreSQL is a powerful, open-source object-relational database system. It has more than 15 years of active development phase and a proven architecture that has earned it a strong reputation for reliability, data integrity, and correctness.
PostgreSQL (pronounced as post-gress-Q-L) is an open-source relational database management system (DBMS) developed by a worldwide team of volunteers. PostgreSQL is not controlled by any corporation or other private entity and the source code is available free of charge.
Run the downloaded dmg package as the administrator user. When you get the screen below, click on the “Next” button:
3. Selecting the install location
You will be asked to specify which directory you wish to use to install Postgres. Select your desired location and click “Next”:
4. Selecting components
You will next be asked to select the tools that you want to install along with the Postgres installation. PostgreSQL server and command line tools are compulsory. Stack Builder and pgAdmin 4 are optional. Please select from the list and click “Next”:
5. Selecting where to store data
You will be asked to select the location for your Postgres cluster’s Data Directory. Please select an appropriate location and click “Next”:
6. Setting the superuser password
You will be asked to provide the password of the Postgres Unix superuser, which will be created at the time of installation. Please provide an appropriate password and click “Next”:
7. Selecting the port number
You will be asked to select the port number on which the PostgreSQL server will listen for incoming connections. Please provide an appropriate port number. (The default port number is 5432.) Make sure the port is open from your firewall and the traffic on that port is accessible. Click “Next”:
8. Setting locale
Please select the appropriate locale (language preferences) and click “Next”:
9. Review and installation
You will be provided a summary of your selections from the previous installation screens. Review it carefully and click “Next” to complete the installation:
Add Dependency:
Run this command:
With Dart:
$ dart pub add postgres
With Flutter:
$ flutter pub add postgres
This will add a line like this to your package’s pubspec.yaml (and run an implicit dart pub get):
dependencies: postgres: ^2.6.1
Alternatively, your editor might support dart pub get or flutter pub get. Check the docs for your editor to learn more.
In the article, I have explained the implementation of PostgreSQL In Flutter; you can modify this code according to your choice. This was a small introduction to the implementation of PostgreSQL In Flutter User Interaction from my side, and it’s working using Flutter.
I hope this blog will provide you with sufficient information on Trying to Implement PostgreSQL In Flutter in your Flutter projects. We will show you what the Introduction is. Make a demo program for working on PostgreSQL with Flutter in your Flutter applications. So please try it.
❤ ❤ Thanks for reading this article ❤❤
If I got something wrong? Let me know in the comments. I would love to improve.
Clap 👏 If this article helps you.
GitHub Link:
You can check out Implement PostgreSQL In Flutter on GitHub. We hope you enjoyed this tutorial
Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.
Feel free to connect with us: And read more articles fromFlutterDevs.com.
FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a Flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! For any flutter-related queries, you can connect with us on Facebook, GitHub, Twitter, and LinkedIn.
Wewelcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.
In this article, we will Explore Sealed Classes In Flutter. We perceive how to execute a demo program. We will show you what is a sealed classes? and how to use it in your applications.
Sealed is a new modifier that was added in Dart 3. It can be applied to define a class or type with a restricted list of subtypes. We would like to create a class called Color, for instance. The Green, Blue, and Red classes are the only three that can be subtypes of the Color class.
Adding a sealed modifier to the Color class is the answer. The class cannot be expanded upon or used outside of its library with that modifier applied. Sealed classes are also inherently abstract.
Subclasses:
Every subclass needs to be defined in the same file, or the same library. An example of declaring the Color class and its subclasses is provided below.
The compiler will raise an error if you attempt to define a class in another file that extends the Color class.
class Item extends Color {}
Instances:
A sealed class’s constructor cannot be used to create an instance since it is implicitly abstract.
Color color = Color();
A sealed class’s subclasses are not inherently abstract. As a result, to create instances, you must use the constructor of the subclasses.
Green myGreen = Green(); Blue myBlue = Blue(); Red myRed = Red('flutterdevs.com');
Constructors:
Constructors defined by a sealed class are accessible to its subclasses. For instance, we add a field called id to the Color class mentioned above. A constructor exists that takes in the value of id. I included a print statement to make it simpler to determine whether the constructor is called when from the subclasses.
To determine whether an object is an instance of a specific class, you can construct a switch case in the Dart programming language. The compiler can notify you if a switch block isn’t handling every possible subtype because a sealed class has a known list of subtypes.
The switch block in the example below doesn’t handle the case in which the passed object is Red. Consequently, an error stating that the switch cases do not fully match the type will be displayed.
String getColorVoice(Color color) { // ERROR: The type 'Color' is not exhaustively matched by the switch cases since it doesn't match 'Goat()' return switch (color) { Green() => 'light', Blue() => 'dark', }; }
Conclusion:
In the article, I have explained the Sealed Classes In Dart; you can modify this code according to your choice. This was a small introduction to Sealed Classes In Dart User Interaction from my side, and it’s working using Flutter.
I hope this blog will provide you with sufficient information on Trying the Sealed Classes In Dart of your projects. If you want to define a class whose list of subtypes is predetermined and cannot be altered later, you should use Dart’s sealed modifier. The same library (file) must declare the list of subtypes.
Classes that are sealed cannot be instantiated and are implicitly abstract. You can, however, include factory constructors and other constructors. When you construct a switch block with a sealed class as the checked object type, the compiler can determine whether the switch cases have already exhaustively matched the type.
❤ ❤ Thanks for reading this article ❤❤
If I got something wrong? Let me know in the comments. I would love to improve.
Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.
Feel free to connect with us: And read more articles fromFlutterDevs.com.
FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a Flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! For any flutter-related queries, you can connect with us on Facebook, GitHub, Twitter, and LinkedIn.
Wewelcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.
In this article, we will explore the Implement Audio Trimmer In Flutter. We perceive how to execute a demo program. We will show you how to trim audio files and save the trimmed audio files to the device utilizing the easy_audio_trimmer package in your Flutter applications.
An audio trimmer is an audio editor intended to cut, trim, or split audio parts. It permits you to eliminate undesirable parts from your audio clips and save the subsequent piece of the audio in different audio files organizations like MP3, WAV, AAC, FLAC, OGG, and WMA.
Audio trimmers fill a crucial need empowering clients to cut and refine audio cuts as per their inclinations. This usefulness tracks down applications in different situations, including making tweaked ringtones, altering, or just extricating important parts from extended recordings.
This demo video shows how to implement Audio Trimmer in Flutter and how Audio Trimmer will work using the easy_audio_trimmer package and in your Flutter applications. We will show you the simplest way to trim and save audio files on your device.
Step 3: Run flutter packages get in the root directory of your app.
Step 4: While running on the Android platform if it gives an error that minSdkVersion needs to be 24, or on the iOS platform that the Podfile platform version should be 11
How to implement code in dart file :
You need to implement it in your code respectively:
Create a new dart file called main.dart inside the lib folder.
In this dart file, we will create a new class AudioTrimmerDemo(). In this class, will add an ElevatedButton(). In this button, we will add the text “Select File” to its child function, and on the onPressed function, we will add the pick-up audio file function.
When we run the application, we ought to get the screen’s output like the underneath screen capture.
Output
In the same dart file, we will create another new class AudioTrimmerViewDemo().
In this class, we will create a final Trimmer variable which is _trimmer is equal to Trimmer(). We will create two double variables _startValue and _endValue equal to 0.0. Also, we will create a three-bool variable was _isPlaying, _progressVisibility, and isLoading equal to false.
In the body part, we will create an audio trimmer view using the TrimViewer() method. In this method, we will set backgroundColor, barColor, viewerHeight, onChangeStart, etc.
Also, we will add the Visibility() method. In this method, we will add LinearProgressIndicator(). This method will work on the save button only. When the user presses save the audio then the LinearProgressIndicator will be shown.
In the article, I have explained the Audio Trimmer In Flutter; you can modify this code according to your choice. This was a small introduction to the Audio Trimmer In Flutter User Interaction from my side, and it’s working using Flutter.
I hope this blog will provide you with sufficient information on Trying the Audio Trimmer in your Flutter projects. We will show you what the Introduction is. Make a demo program for working on Audio Trimmer in your Flutter applications. So please try it.
❤ ❤ Thanks for reading this article ❤❤
If I need to correct something? Let me know in the comments. I would love to improve.
Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.
Feel free to connect with us: And read more articles fromFlutterDevs.com.
FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a Flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! For any flutter-related queries, you can connect with us on Facebook, GitHub, Twitter, and LinkedIn.
Wewelcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.