Hello Everyone, This article is about how to paginate your data from the Firebase firestore.
What is Pagination?
“Pagination, also known as paging, is the process of dividing a document into discrete pages” When we gradually load the chunks of data and display it. It’s efficient, quick, and server-friendly to split the results up into multiple data set . if we fetch all the data at one time then things start slowing down the more results which are returned.
What do we want?
We are fetching the data from the firestore in chunks and display it our app.
Fetch data from firestore
We need to fetch all the documents from the movies collection, if we fetch all the data at once, it will be very hard to handle so we need to fetch the data gradually.
we will check every time a list reaches at the end and then we fetch the next list.
void _scrollListener() { if (controller.offset >= controller.position.maxScrollExtent && !controller.position.outOfRange) { print("at the end of list"); movieListBloc.fetchNextMovies(); } }
Let’s define the fetchNextMovies() in our MovieBloc.
when we fetch the next list, we are appending the documents in the existing list and sink the documents in3 the stream and update the UI using StreamBuilder .
To get the more idea, have a look at more way to paginate your data
Paginate data with query cursors | Firebase With query cursors in Cloud Firestore, you can split data returned by a query into batches according to the parameters…firebase.google.com
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 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, and Twitter for any flutter related queries.
We welcome feedback, and hope that you share what you’re working on using #Flutter. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences!
Thank you for reading. 🌸
Need expert help building your Flutter app?Talk to FlutterExperts for architecture, development, and consulting support.
Hello folks!, If you are a Flutter Developer you could have better or bitter experience while developing apps that require you to manage states as well. In flutter, there are various techniques for state management some of them are:
setState()
Inherited widget & Inherited Model
Provider & Scoped Model
Redux
BloC/Rx
MobX
Flutter_BLoc
As a flutter developer, I have experienced that all techniques are best but all have their benefits while flutter_bloc contains important and valuable things from other state management techniques mentioned above.
Why Bloc?
When we are building production quality application state management becomes a critical issue and being a developer we only want to know a few things and these are
How states are changing.
How an application is making interaction that actually helps to make data-driven decisions.
Is the developer able to work with a single code base following the same pattern?
fast and reactive apps.
and it is designed with three core values in mind and these are simplicity, powerfulness, and testability.
Before working with it we need to understand what its inner widgets do and how we manage our data with, Now firstly we have to get the basic knowledge of flutter_bloc.
Basic design patterns are used to make the project well managed, responsible, scalable, and optimized so the flutter_bloc does.
Implementation:
Step 1: Add the dependencies
Add dependencies to pubspec.yaml file.
dependencies:
flutter_bloc: ^latest version
Step 2: Import
import ‘package:flutter_bloc/flutter_bloc.dart’;
this is the installation flutter_bloc now let’s move to understand
core conceptsof the bloc.
There are various core concepts of the bloc to understand its working,
Events
Events are the inputs of the bloc and it is generally done by making an interaction by the user
Interaction, while designing an app is the basic task and in the upcoming example, we will better know how to fire an event during an interaction.
Generally, we fire an event when we make any interaction when we call onTap but here in the example, we will be making an API call without any button interaction so the event will be fired when we will be instantiating it in main.dart
States are the output of the bloc, it notifies the UI component of the app and helps it to rebuild itself according to the state.
As we have defined event in the app and it is for fetching data from API, then it will be mapped into the state by bloc and UI will be redrawing itself according to it.
class UserDetailsLoadedState extends UserDetailsState { UserResponseModel userResponseList; UserDetailsLoadedState(this.userResponseList); }
Transition
Transition helps to find out changes from one state to another, It holds the current state and the event and the next state
Basically, it helps to observe when and where states are getting changed It depends on the developer if he/she wants to use it or not.
Now after a small introduction let’s move to the core concept of Flutter Bloc
Bloc
Bloc (Business Logic Component) converts the incoming stream of events into outgoing stream of states
Every bloc converts every event into the state, and it can be accessed by using state property
Bloc Builder is a flutter widget that requires bloc and builder functions and it manages the widget according to new states
BlocBuilder<BlocA, BlocAState>( builder: (context, state) { // return widget here based on BlocA's state } )
BlocBuilder also contains few properties like bloc and condition for a specific purpose like when you want to specify a particular bloc and previous bloc. You can find a brief description here.
BlocProvider:
It is used as a dependency injection so that it can provide bloc to its children, there are different types to implement it but it depends on no. of blocs are implemented in any app, for single bloc you use BlocProvider.of<T>(context) but if you are managing your app by multiple blocs the MultiBlocProvider will be used to implement it
Now let’s implement it, for the sake of simplicity first create a package in the lib and make different classes for the event, state and bloc,
after this first, we make an event in the event class that will be fired when the application will start for fetching data.
abstract class UserDetailsEvent { const UserDetailsEvent(); }
class FetchUserDetailsEvent extends UserDetailsEvent { FetchUserDetailsEvent(); }
then we make all possible states which could happen in state class, state class must contain initial state because it is the state before any event has been received.
class UserDetailsState {}
class UserDetailsInitialState extends UserDetailsState {}
class UserDetailsLoading extends UserDetailsState {}
class UserDetailsLoadedState extends UserDetailsState { UserResponseModel userResponseList; UserDetailsLoadedState(this.userResponseList); }
class UserDetailsError extends UserDetailsState { Error e; UserDetailsError(this.e); }
there could be four possible states like
initial state,
loading state: when data is loading,
loaded state: when data is loaded,
error state: if we found any error.
Now let’s move to the bloc, here bloc mapEventToState means which event is fired will be converted in to map, in this code snippet we have called that event which we have fired from event class and all four possible states are used.
class UserDetailsBloc extends Bloc<UserDetailsEvent, UserDetailsState> { UserRepository userRepository = UserRepository();
@override UserDetailsState get initialState { return UserDetailsInitialState(); }
now let’s understand how we call API using retrofit, for this, we have to add few dependencies retrofit, json_serializable,build_runner, and retrofit_generator
then we define and generate API and for this, you should have at least JSON parameters and then you to define it as mentioned below
here one thing is very important which is @JsonKey(name: “ ”) becuase if JSON response is containing key like “per_page”
then during the parsing, it would give an error, so you need to define it by @JsonKey(name: “per_page”) above the particular key.
then we write the factory method as it is, now it may contain few errors but leave it for now, we will handle it a few steps later
we implement HTTP methods and add parameters required
after this, we import
part 'class_name.g.dart';
in JSON model class(you can see above model class) run a command in the terminal,
flutter pub run build_runner build
here you will observe those errors have gone because all the required methods have been generated automatically and if you make any changes in it then you have to run the next command in the terminal,
flutter pub run build_runner build --delete-conflicting-outputs
the auto-generated files will be refactored.
after we call this API in bloc class and we fetch all the details using state in Our UI
Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.
FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire 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, and Twitter for any flutter related queries.
Need expert help building your Flutter app?Talk to FlutterExperts for architecture, development, and consulting support.
Images are major to each application. They can give urgent data by filling in as visual guides or just working on the stylish of your application. There are numerous ways of adding an image to your Flutter application.
At the point when you make an application in Flutter, it incorporates both code and resources (assets). An asset is a document, which is packaged and sent with the application and is open at runtime. Showing pictures is the major idea of most versatile applications.
This blog will explorethe Rendering Image From Byte Buffer/Int8List In Flutter. We will see how to implement a demo program. We are going to learn about how we can render an image in your flutter applications.
Perusing byte data from a given URL of an image and you can change this move to suit what is happening, like getting byte data from a file or a database Utilizing Image. memory to render the image from byte data.
Demo Module :
The above demo video shows how to render an image in a flutter. It shows how rendering an image from a byte will work in your flutter applications. It shows an image with its URL instead of the detour of getting its bytes from the URL and then using this byte list to display the image. It will be shown on your device.
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 Flutter, you can render a picture from an Int8List of bytes by utilizing the Image. memory constructor like:
Image.memory(Uint8List.fromList(myBytes));
Assuming that what you have are byte buffers, utilize this:
In the main. dart file, we will create a HomeScreen class. In this class, first, we will add Int8List byte data that will be used to render the image.
Int8List? _bytes;
Now, we will create a _getBytes() method. In this method, we will get byte data from an image URL. Inside, we will add the final ByteData data is equal to the NetworkAssetBundle(). We will add _bytes is equal to the data.buffer.asInt8List().
void _getBytes(imageUrl) async { final ByteData data = await NetworkAssetBundle(Uri.parse(imageUrl)).load(imageUrl); setState(() { _bytes = data.buffer.asInt8List(); print(_bytes); }); }
Now, we will create an initState() method. In this method, we will add _getBytes(Your Url’).
@override void initState() { // call the _getBytes() function _getBytes( 'https://upwork-usw2-prod-assets-static.s3.us-west-2.amazonaws.com/org-logo/425220847461273600'); super.initState(); }
In the body, we will add the Center widget. In this widget, we will add _bytes is equal-equal to null then, show CircularProgressIndicator. Else, show an Image.memory(). Inside this function, we will add Uint8List.fromList(_bytes!), width, height, and fit is equal to BoxFit.contain.
In the article, I have explained the Rendering Image From Byte Buffer/Int8List basic structure in a flutter; you can modify this code according to your choice. This was a small introduction to Rendering Image From Byte Buffer/Int8List On User Interaction from my side, and it’s working using Flutter.
I hope this blog will provide you with sufficient information on Trying upthe Rendering Image From Byte Buffer/Int8List in your flutter projects. We will show you what the Introduction is. Make a demo program for working with rendering an image from Int8List 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.
Need expert help building your Flutter app?Talk to FlutterExperts for architecture, development, and consulting support.
Hi everyone, In this article, we will be learning how to implement the dark theme in our app using the provider package
As we all now Dark theme is trending and most of the popular app has the feature to turn into the dark mode.
There are two ways to turn on the dark mode in any app:
1: Adding a custom option to change to the dark mode (Eg: Twitter, Medium app)
2: Depends on the Phone system setting (Eg: Instagram)
We already have both the options in flutter.
If you check the MaterialApp widget you will see
We have the theme and darkTheme parameter in MaterialApp widget we can provide the dark ThemeData in darkTheme and light ThemeData in theme if we want our app to change the theme according to the system preferences.
And if we have a custom button or something to change the dark theme then we just have to put some condition to change it.
we are using the SharedPreferences to set the value in the memory so even if we close the app and reopens it, our data won’t lose. Provider is used to manage the state when the dark theme is implemented on the app.
We are creating a separate class for the SharedPreferences so the code won’t mess up.
We have created a class DarkThemePreference where we are storing the bool value in for the dark theme, we have two methods for saving and retrieving the bool value.
We are accessing the preference value through the provider so whenever there is any change the notifyListeners() UI will be updated if we have attached the provider to the screen.
Step 4: Add custom theme data for dark mode
if you see we have to provide the ThemeData , so I have created a method for dark and light mode.
If you see the getCurrentAppTheme method, I am fetching the value from the preferences and set the value in the provider.
Now we will add notifier to the material app which is ChangeNotifierProvider and set a provider model to it, if any change happens in the provider it will notify its descendants.
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.
As we all know Flutter has come up with new announcements in Flutter Interact which was recently held on Dec 11, 2019. Generally, developers eagerly wait for new announcements that Google Flutter is going to make and then observe and work with them, this time also Google Flutter wanted to make it a big release and for that, they prepared for it. In this release according to flutter they have merged 1905 pull requests from 188 contributors including Google and non-Google contributors.
Since its first release from Flutter 1.0 to Flutter 1.12, it’s 5 stable versions have been released and the flutter team always improved its shortcomings and in Flutter 1.12 they have come up with few new concepts and were focused on the concept of Ambient Computing.
Before we review announcements of Flutter 1.12 let’s take the overview of Ambient Computing.
Ambient Computing: When developers start developing an app they always find themselves in the dilemma that which gadget they need to aim while they are developing an app.
Actually, the fact is we daily use different internet-connected devices with the same purposes so the Flutter development team has decided to create a milieu that makes users use all services across all the devices now they have come with the concept of “ Write Once, Read Everywhere” and this is the ambient computing.
In all the flamboyant announcements this is the most awaited release because it is addressing one important problem which will help to handle and prevent errors when variable get a zero value and parse an integer. This string handling ability makes it the richest among all.
Beta web Support
Flutter for Web has been an astonishing release among the developer community and now the Flutter development team has added another feather in the cap by shifting it into beta version and by making it easier to apply Dart Compiler and Flutter architecture efficiently.
macOS Desktop Support
In this segment, developers will able to use release mode to develop a fully optimized macOS application with the help of Flutter
Desktop app support got rich with various new updates like menu dropdown keyboard navigation, visual density assistance, checkboxes, radio buttons and many more.
Linux and Windows support is also in the up-gradation Stage and soon will be upgraded.
iOS 13 Dark Mode
Flutter 1.12 also described the addition of complete dark mode in iOS13, previously flutter also provided support for auto toggling to dark mode on Android 10, all the iOS-like widgets, named Cupertino are available in dark mode. they can automatically be enabled by turning the dark mode on.
Another Feature of Flutter 1.12 is it makes developers enable to add flutter in the current Android and iOS app, Migration of an app in flutter is possible once, instead of creating it from the beginning.
Here in this video of Flutter dev, you can get an idea of doing it easily.
In updated DartPad not only the entire code can be edited but also can be assessed the rendered UI and running the flutter code efficiently.
Adobe XD to Flutter Plugin
Now flutter has come up with a new collaboration with Adobe XD and XD is accessible for flutter plugins. Actually flutter is trying hard to make developers work easy and this is the kind of effort where the latest XD in Flutter changes the XD designs automatically into code and makes it usable part of flutter development.
New Google Fonts Package
Flutter added this improvement in order to beautify user experience by adding 1000s open-source font families.
It helps to designers to add different typography while developing within a few code lines.
Multi-device Debugging
As a developer, we always develop and debug our flutter UI and when we want to debug it on different devices we need to debug it separately for the individual device but now flutter has come with the solution for this by adding multi-device debugging.
These were the important new features every developer should go with.
What is really needed to make it more efficient and compete with others
Flutter is trying hard to take the lead over the debate on Flutter Vs React native and this is a gamechanger effort that is surely going to get a lead. After all these announcements if we are still missing something which is pushing of codes of the designed apps directly.
Hope Flutter team will surely work on it and in upcoming announcements, we might see some new features in all segments.
Thanks for reading this article, if you find something you better know Please let me know, I will welcome it with full gratitude.
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 from FlutterDevs.com
FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire 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, and Twitter for any flutter related queries.
For AppBar , I have created a separate widget method because you must have seen in apps when selecting it’s the app bar changes. We also need to update the app bar whenever we are selecting items.
We will check in the selectedList length whether it has any item in the list and change the app bar accordingly.
I have added the delete button on the AppBar to delete the item in the itemList that are present in the selectedList .
If you are wondering why I am using the key because when I was deleting the values it was only updating in the widget tree but not exactly in the element tree.
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.
firebase_ml_vision uses the ML Kit Vision for Firebase API for flutter that is built by the Flutter team. We also need the camera plugin to scan the text.
To show the outline we can draw them by using CustomPainter because of the VisionText parameters provide the TextContainer and we can find the coordinates and draw on it.
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.
Hello Folks! We all are working in flutter and most of the time we all need to work with Callback and VoidCallback because we need to send data from one method to another and vice versa.
if you are a beginner then chances are you are struggling to handle the flow of data actually there are various ways to do that but Callback is the best suitable way to handle this. So lets first understand What is Callback ??
Callback:
If we go by definition, the Callback is a function or a method which we pass as an argument into another function or method and can perform an action when we require it.
Let’s understand why we use it
For Example, if you are working in any app and if you want any change in any value then what would you do?
Here you are in a dilemma that what you want to change either state() or a simple value/values. If you need to change states then you have various state-changing techniques but if you want to change simple values then you will use Callback.
Let’s Understand it by a small example I have made to make you understand,
here are two images below one is showing a text(“Want to change Text”) and a button by which you will navigate to next screen, In next screen, there is a text field and a button which navigate to the previous screen with the changed text you will enter in the text field.
here in the above code snippet, a text is defined which is a default text and when we will receive a String value from callback it will be changed, then we will navigate to next class where we will perform Callback
here in the EditingPage we have defined the Callback function
typedef VoidCallback = void Function();
which will return the value we will change to the previous page,
In the EditingPage class, Callback function has been initialized and below in code with the help of controller value has been assigned to it, when we will navigate to the previous page we will receive it here
here the value which has been sent by using Callback is being initialized to the “editableText “ variable and it will update the text.
So simple idea is that when you want to change any value you can use Callback and can handle the data flow easily.
So it was a small explanation to make you understand actually how it works and why and when you should use it.
Thanks for reading this article, if you find something you better know Please let me know, I will welcome it with full gratitude.
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 from FlutterDevs.com
FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire 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, and Twitter for any flutter related queries.
Before I explain anything about it, chances are you have come across various blogs in which you have studied almost everything you should know about Flutter.
This year has been a thriller to mobile developers because mobile developers had various options to develop their app but with the introduction of Flutter whole scenario changed rapidly and the community found their new crush to pay attention to.
Now instead of explaining about flutter, I would recommend you visit the official Flutter site to get some knowledge about it.
After reading from the official site let me explain a few key points to summarize it.
Flutter consists of an SDK that helps to develop your application and compile code of iOS and Android. It also consists of a UI library of toolkits.
What would you get from Flutter:
1. Same Codebase for all platforms
In flutter, the developer needs to write a single code base for all platforms and this is one of the biggest advantages flutter developers have, here you have the same business logic and same UI in all platforms whether it is android, iOS, web it enables you to work in the concept of write once run everywhere.
2. Hot-Reload
In the native platforms, it has always been a problem to observe sudden and small changes while writing code and especially during UI design, Flutter has overcome this drawback with its hot-reload feature. It will not only help you to fix bugs easily but also add new features without compromising its speed.
3. Architecture
Building an app is easy but managing it according to business logic is quite a critical task so you need to follow an architecture to manage it and MVP(Model–view–presenter)is the best suitable architecture for it. its benefits in easy integration, maintaining speed and responsiveness of it.
4. Performance
If you compare native apps and flutter on the basis of its performance in the flutter code is written in dart and which excludes JavaScript bridge and it helps to boost its performance in terms of speed which is 60 FPS.
5. Dart
This is another reason why developers love flutter because Dart is an object-oriented, garbage-collected, class defined, language using a C-style syntax that trans-compiles optionally into JavaScript.
Let’s just understand a few key features of dart:
AOT Dart uses ahead of time compilation and because of it not only it helps to start fast but also to customize its Flutter widgets.
JIT Dart also uses JIT means just in time compilation which enables you to use the feature of hot reload.
Garbage Collector Dart is also enabled with the garbage collector in the language it helps flutter to function smoothly and enables it to achieve 60 FPS. Dart has similarities with other languages and this quality makes dart so powerful for development.
6. Material Design
In every technology, there are some key features that make the technology different from others in the league and in the Flutter material design has this opportunity. For using the material design you only need to use this widget and it will enable you to material design guidelines throughout the app. While in native platforms it is not that easy.
7. Add to App
Another Feature of Flutter 1.12 is it makes developers enable to add flutter in the current Android and iOS app, Migration of an app in flutter is possible once, instead of creating it from the beginning.
Here in this video of Flutter dev, you can get an idea of doing it easily.
You can find out all the new features including this in this blog written by me mentioned below.
Testing has always been an important part and it the native and in the flutter, both have a bit the same testing procedure but there are also some differences that make it fast in a flutter.
Native
Unit Test
Integration Test
UI Test
Flutter
Unit Test
Integration Test
Widget Test
In native we have various testing frameworks for Unit Testing like JUnit and Mockito for running unit tests and Espresso for UI test.
In Flutter there are also three components of testing and the widget test is quite similar to UI test, you can also use Mockito by using Mockito package in the flutter, for integration test you can add a package flutter_driver.
9. Animation
In flutter, there are some inbuilt basic animations to make beautiful applications but if you want to add more animations in your app there is Rive (previously 2Dimensions)to make your wish completely true, by importing Rive directly you can add it.
10. Fuchsia
Fuchsia is being developed by Google which is an open-source operating system and as explained by Google flutter has been developed keeping Fuchsia in mind. These days it is a need of time a common operating system that can run on smartphones, desktop, embedded systems and many more and Fuchsia has its own micro-kernel called Zircon.
After these small discussions now its time to pay attention to whether Flutter will make it’s ground big if we compare to native, actually flutter is still in the development phase and new libraries and plugins are still adding in its armory. So we can hope new and big announcements on this.
Thanks for reading this article, if you find something you better know Please let me know, I will welcome it with full gratitude.
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 from FlutterDevs.com
FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire 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, and Twitter for any flutter related queries.
Themes have always been an Omnipotent part of User Interface for app developers. With the recent key advancements in app developing process, Customisation in themes is an apparent need of developers.
Flutter has although to whopping extent ease off the process of customising themes & their individual components. Here, In this article we are going to create Multi themes using providerstate management technique :
For Beginner’s, Do Checkout this video of Google I/O’19 For Dark Theme:
Dark themes has been introduced in flutter which is easily applicable by either through the app settings or phone settings. Dark themes is a hot buzz nowadays as it reduce the luminous emission through screens which-in-turn helps in reducing the blue ray emitted by devices preventing eye strain, adjusting brightness to current lighting conditions, and facilitating righteous screen use in dark environments — also longevity of battery life.
This article assumes you have Pre-requisite knowledge about: Inherited Widgets. If you don’t know about Inherited Widget, these are some interesting articles about them, for example here :
Let’s Begin :
1.Firstly, Create a new project and then clear all the code in the main.dart file. Type below command in your terminal:-
flutter create yourProjectName
Add the current latest version of provider package under the dependencies in pubspec.yaml file.
dependencies: provider: ^latest version
2. Have a look at the snippet for better understanding:
As we can infer from the above snippet:
Multiprovider state management has been used for the state management in with its child as MyApp().Provider consist of ChangeNotifierProvider in which non-nullcreate a ChangeNotifier which is automatically disposed up on its removal from widget tree.
In ClassMyApp(), Consumer is used which Obtains Provider<T> from its ancestors and passes its value to the builder.Also, In MaterialApp routes and ThemeData elements are provided using model class.
Create Theme:
We can create multiple themes as referring to our needs via the help of panache( a flutter theme editor) . Themes once created, we create a ThemeModel class to notify us of a theme change through with the help of notifylisteners each time a change is occurring so that it will notify them to its descendants:
One involving Change of Primary maincolor from the Multi theme option and other giving some custom changes which can be made by picking the appropriate shadecolor from the colorpicker .Though here , I have restrained myself for only some custom changes but the list is growable as we have multiple attributes which can be changed up in MaterialApp.
Custom & Main Option:-
All the attributes can be mutated by selectively choosing the shadecolor from the colorpicker in the custom tab whereas the generic option will apparently change the primary main colour On-tapping the right container, tapping is made sure of with a display of Toast.
Using a Custom Font Family:
A discrete directory named fonts withfont-family Gilroy has been added that is further defined in pubspec.yaml as-
Also, Check the module used in the blog from here.
Closing Thoughts
Themes are a Quintessential tool in modern applications as they provide us with the ease of customising User-Interface of the app as per user needs. They also provide the app it’s fondness and customizability as per particular needs. The key purpose of this article is to avail you an Insight of How we can create multiple themes based flutter application using Provider State management technique.
If you have not used Themes, I hope this article has provided you with content information about what’s all about Multi-theme, and you will give it — a Try. Initiate using Themes for your apps. !!!
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 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, and Twitter for any flutter related queries.
We welcome feedback, and hope that you share what you’re working on using #Flutter. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences!