As you all know dart is client optimized programming language for multiple platforms and that special term client optimized always indicates that Dart will always come with more suitable and optimized techniques to make developers work with ease. the same thing happened during the announcement of Dart 2.6 when extensions were introduced however that was for a preview but it was finally released in 2.7. Basically extensions feature is the way to add functionality to existing libraries.
If we understand extension methods by a scenario then it would be like
When you’re using someone else’s API or when you implement a library that’s widely used, it’s often impractical or impossible to change the API. But you might still want to add some functionality.
then the most probable solution for that is by writing wrapper classes with static methods and members and it could cause an increase of the number of objects and then extensions feature come in to play.
Sometimes you might get confused in order to clarify the difference between wrapper and extensions so for your information
In Wrapper classes object is passed explicitly to the static methods while in extensions it is extended implicitly.
So this was basic introduction now let’s clarify a few things about extensions
How can we use extensions
where it is suitable to use and where we should refrain from it
Implementation
Before going over implementation of the extension the first thing which you need to pay attention to is the Dart SDK version. This should be ≥ 3.3, inside your pubspec.yaml
environment:sdk: ">=3.3.0 <4.0.0"
The syntax for the actual implementation
extension <extension_name> on <type> { (<member_definition>)* }
Example
Let’s understand it by example, suppose if you are getting data from any third-party API and you are getting value in Celsius but need to show it in Farhenheit, what would you do ??
but what if you need show throughout in your application then you can do this everywhere but there would be a lot of boilerplate code so here extensions come in because you don’t need to call extensions methods by its name
In this example, you can see how we are doubling the values of the list by using extension methods and the output will be
Price listing after doubling the value [4, 10, 13.5]
That was Dart portion, now let’s understand with Flutter
Suppose you are designing UI of app and there are numerous circular Cards where you need to define its shape everywhere so you need to call that circular property everywhere then again we would write the extension method for this see in the example
for the extension methods, we make a separate class where all different extensions are described and we only need to call them.in this example, you can see that we are calling shape from the extension method
extension methods are defined by using extension keyword after that we will be able to call all methods without creating any instance variables.
Conclusion
In conclusion, we found that as a developer we have also options to get rid off of a lot of boilerplate and it helps to use the property of any method without creating any instance variables which a big boon when it comes to using any method from different classes.
Thanks for reading this article if you find anything that could be improved please let me know, I would love to improve.💙
If this article has helped you a bit and found interesting please clap!👏
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, 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!.
Agile Methodology is one of the most commonly used practices in project management in current times. The benefits that the method provides such as increased business value, faster go to market, greater transparency among the team, and better quality management is enough to push a number of businesses across a range of industries to follow the Agile approach in their everyday work process.
If your business, seeing the benefits that the methodology has to offer, is also planning to take the agile scrum development route, this article is for you.
Agile Method In the context of Mobile App Development
Holistically, the role of Agile in mobile apps is well-renowned and Scrum is the most commonly used subdomain of the agile methodology, which has quickly expanded to handling big, complicated projects that might have otherwise taken a lot of time to finish.
Mobile application development and keeping it updated in the current scenario is quite a complex process. Even more complex is the task of getting it downloaded on the user’s devices, and used frequently. It is because of a large number of apps available in the marketplace. While a majority of users use the smartphone, it is quite easy to get noticed, but it becomes quite challenging to get the user’s attention as in this gigantic sea of options available for them. Hence it becomes quite necessary for the business owners to design the best app in a short span of time and keep their apps updated as per the latest trends.
Before getting into the details about the Agile methodology of mobile app development, it is necessary to have a brief idea of Agile technology.
What Exactly is Agile?
Agile is an iterative and step-by-step software development methodology. Agile application development helps organize designing and planning methods, development, and testing methods during a software lifecycle. All methods of Agile are based on the following principles:
quick response to any changes with the help of adaptive planning.
joint elaboration of requirements.
rationalization of tasks performed by the development team
step-by-step software development with strict time frames.
How Does Agile Work?
Since the Agile app development methodology consists of a few short cycles (2–3 weeks each), there is risk minimization. A customer can see the result after each cycle, and he/she can request to make any changes. Thus, a customer has a direct influence on the development and he/she controls it. Each Agile application development lifecycle includes the following stages:
Requirement analysis
Design
Development
Testing
Deploy
Review
One cycle isn’t enough for building a full-fledged product, but each iteration shows part of the functionality that can be tested and/or changed. After each cycle, the development team sums everything up and can receive new requirements, then some adjustments can be made in the software development plan.
Why is Agile Methodology Good For Mobile App Development?
Now let’s speak about the application of Agile in mobile app development and why use Agile methodology. What particularities do mobile apps have? Unlike conventional desktop applications for PC that may function for a few years without an upgrade, mobile apps should be much more flexible for users. Users’ demands may change rather often, so app owners should update this app every time when it requires new changes. And what is the way to create a high-quality mobile app without additional revisions? Agile methodology is the option.
In-Depth Planning in Real-Time Mode
It can be rather difficult to prepare a plan for the whole development process. Using Agile methodology for mobile application app development, we can prepare a plan for each cycle separately, we don’t waste extra time and resources to fix any bugs since everything can be fixed after each stage of implemented functionality. So we can make a proper plan for each stage without any problems, and it will help us create a first-rate product. By the way, if you should also know how to arrange budget planning for your software project.
Sprint by Sprint
With the help of Agile, we create the software sprint by sprint, as we indicated before. We call each cycle as sprint since it is similar to run on a short distance. We don’t aim to complete the project as quickly as possible, we test and check functionality after each sprint to see whether it works properly or not. Besides that, with Agile we can keep up with more strict deadlines.
Quick Changes
Due to the Agile methodology in mobile application development, it is very convenient to make changes in the app since it is divided into sprints. Thus, it will not have a negative impact on the development process, and changes can be made quickly. Because when the project is almost finished and some serious problems arise, revision can take much more time and money, so Agile methodology helps avoid such situations.
Efficient Risk Management
Users won’t use an app that doesn’t function properly or it has many bugs. It will lead to a total failure of the app. That is why an app can be released step by step with Agile methodology, in the beta version first, to make it possible for users to assess an app and notify about any bugs if they find it. On the basis of it, developers can make all changes quickly, and all risks can be managed timely. Existing bugs will be detected as early as possible. You can see how we organize risk management when we create your app.
Complete Transparency
It is not an acceptable situation when a customer sees a result of the development in the end. If something doesn’t meet expectations of a customer, it will be more difficult to revise the app, it will lead to additional costs and time, and, as a result, to negative feedback from a customer. Agile methodology allows the development team to be always in touch with a customer, provide him/her with an app when each sprint is completed, and if we need to make any changes — we do it quickly without damaging development processes.
So, you can see the main benefits Agile mobile app development methodology brings for mobile app development. Now, let’s move to the most popular framework of Agile.
Benefits of Agile Over Traditional Project management Method
Many developers and project managers prefer to use the agile methodology for a variety of reasons. Some of them are discussed below:
More flexibility
When it comes to making changes in the product or a process, agile methodology is much more flexible than the waterfall methodology. While working, if team members feel that there is a need to experiment and try something different than as planned, the agile methodology easily allows them to do so. The best thing about this methodology is that it focuses more on the product than following a rigid structure.
Unlike the traditional approach, agile methodology isn’t linear or follows a top-down approach. So, any last-minute changes can be accommodated in the process without affecting the end-result and disrupting the project schedule.
Transparency
In agile methodology, everything is out there and transparent. The clients and decision-makers are actively involved in the initiation, planning, review, and testing part of a product. Whereas in the traditional approach, the project manager is holding reins of the project, thus others don’t get to make the major decisions.
Ownership and accountability
In traditional project management, a project manager is the person of the ship which means that the entire ownership belongs to him/her. Customers are also involved during the planning phase but their involvement ends there and then as soon as the execution starts.
In the agile methodology, every team member shares ownership of the project. Each one of them plays an active role to complete the sprint within the estimated time. Unlike traditional project management, everyone involved in the project can easily see view the progress from the beginning to an end.
Scope For Feedback
In the traditional approach, every single process is clearly defined and planned from the beginning of the project. The project has to be completed within the estimated time and budget. So, any big change or feedback that might push the deadline is skipped. Whereas agile management allows constant feedback that is helpful in providing better output.
Scrum
Scrum is another prevalent agile methodology process that implements flexible process control for complex software projects. It also makes use of iterative and incremental practices. Based on the hypothesis that we cannot define the final requirements of the project, in the beginning, the knowledge is gained over the due process from the mistakes made over time. It solely focuses on checking the progress of the project and resolve the difficulties as soon as it is encountered in frequent meetings. It provides the advantage that it helps to take action as and when the requirement changes.
Scrum approach divides the working process into equal sprints — their duration may vary, everything depends on the specific project. Before we start a sprint, it is necessary to draw up tasks for this sprint. When it is completed, all results are discussed. This method makes it possible to lower development costs and make the management process more efficient.
Scrum Development: Responsibility Participants
The techniques of Scrum has become very popular and now considered to be the most important thing to do before starting any project. That is why the demand of the scrum masters and other professions related to the scrum has also increased, and people now are searching about the term scrum more.
The scrum is a very specific and précised framework that is why it comprised of the following roles.
Scrum Master
Product Owner
Scrum Team
Stakeholders
Scrum Master is someone who is responsible for solving any sort of problem that the team is facing while building the product. It is not necessary for him to completely understand the requirements; he must be capable enough to find solutions to situations. He has to create and maintain the best possible working condition for the team members so that they can meet the goals of each sprint effectively.
Product Owner is the one who shares the vision of the project (or the product to be developed), prioritizes the functionalities to be built and makes key decisions on behalf of the team or the project. While during project execution, the product owner is the one who is responsible for maintaining the product backlog, bridging the gap between the developers and other stakeholders, managing the end-user (or customer) expectations, and managing the budget (ROI). He is also the one who takes a call on the quality of the product and if it requires any improvement.
A Scrum Team is cross-functional team that is responsible for developing the product. It is a small team consisting of developers, business analysts, testers, etc. The team works together and in tandem while building the application. The activities of each of the team members are aligned in a way such that the targets associated with a specific sprint are achieved. Team members are also responsible for identifying the complexity of the tasks (assigned to them) and allocating efforts (in a number of hours/days) to those.
Conclusion
The agile application development process bears a lot of advantages both for the development team and for customers. We can affirm it as we are highly experienced in it. The methodology makes it possible to build a mobile app that will be accepted by the public with admiration. The only thing you need is a high-skilled software development team that will turn your ideas into reality.
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. Team FlutterDevs has been building remarkable mobile apps in Native, Hybrid, and Cross-platform over a decade now. Hire a flutter developer for your 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.
Ever wondered how flutter handles all your UI building and events like Futures, taps, etc.. on a single thread( yes it does all that on a single thread 😮😮😮 until and unless explicitly done).
What is Thread/Isolates ?
Thread is an independent process that has its own chunk of memory and executes the given instructions on that memory , It can work parallelly with other threads hence can reduce execution time of multiple process on a single thread .
Let’s understand this with an example :
In Fps games like counter strike, Call of duty, etc. you can see that as soon as you fire a weapon few tasks executes simultaneously like playing of bullet sound, change of bullet count and reduction in opponent health , All these things happens parallelly these are basically threads which execute parallelly and execute their task on separate isolates(isolates and threads can be used interchangeably as isolate is a Dart way of multi threading more on that below) which have its own memory.
Languages like JAVA and C++ Share Their heap memory with threads, but in case of flutter, every isolate has its own memory and works independently. As it has its own private space this memory doesn’t require locking, as if a thread finishes its task it already means that the thread has finished utilizing its memory space and then that memory can go for garbage collection.
To maintain these benefits flutter has a separate memory for every isolate(Flutter way of multi-threading) that’s why they are called isolate 🙂.
Learn more about isolates below.
How can it be helpful to me and where should I use isolates/Threads?
When to use isolates/threads ?
There are a few situations where isolates can be very handy.
Let say you want to execute a network call and you want to process that data that you just received . and that data contains about million records that alone will hang your UI.
You have some image processing tasks that you want to do on-device these kinds of tasks are highly computational as they have to deal with lots of number crunching operations which may lead to frozen UI or legginess in UI.
So to conclude when to use isolates, We should use them whenever you think there is a lot of computation that needs to be offloaded from the main thread.
How to use isolates ?
Flutter team has designed a very elegant and abstract way of using isolates/threads in a flutter, Using compute we can do the same task which isolates does but in a more cleaner and abstract way. Let’s take a look at the flutter compute function.
Syntax:
var getData = await compute(function,parameter);
Compute function takes two parameters :
A future or a function but that must be static (as in dart threads does not share memory so they are class level members not object level).
Argument to pass into the function, To send multiple arguments you can pass it as a map(as it only supports single argument).
compute function returns a Future which if you want can store into a variable and can provide it into a future builder.
Let’s start by analyzing a sample problem:
/media/247dce48c8ac87e5b91b48cd11740086
In the above code pausefunction() is called just below the build method which pauses the execution of code for 10 seconds. And because of that when you try to navigate to this page from a previous one there will be a delay of ten seconds before our page gets pushed on to the widget tree.
As you can see now we have declared our pause function as async even doing this will not help
As async in dart is basically puts our code in ideal until there is something to compute so it seems to us that dart is executing these on a different thread but actually it’s just waiting for some event to occur in that async function.
In the above code, we basically passed our function in compute() function and that creates a separate isolate to handle the task and our main UI will still run without any delay (check the debug console for response ).
Summary:
Dart is by default executes all its code on a single-threaded.
Every function and every async-await calls work only on the main thread(until and unless specified).
We can create multiple threads using compute( Future function/normal function, argument).
You can use compute for executing network calls, performing number-crunching calculations, image processing, etc.
This is all about compute to learn more about isolates (the underlying architecture of computing function) check out isolate .
Thanks for reading this article.
If you find it interesting Please Clap! and if you found anything wrong please let me know I would appreciate it for your contribution.
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, 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!.
In this blog, we shall discuss user authentication using firebase in flutter. We will learn authentication using twitter, email, and password, anonymous methods.
Open firebase, click on get started which will take you to the Add Project screen.
Enter the project name and complete the other essential steps. It will take you to your project screen, click on the android icon.
Now the steps which are coming are very important so please do them very carefully. You have to enter the package name which is generally your application Id in your app-level build.gradle file. Add the other two optional fields if you wish to add them as well.
Now download the google-services.json. Move the downloaded google-serivces.json file into your Android app module root directory. (NOTE: Please check the file that you have downloaded has a google-services.json name or not because if you download it more then one time the name of the file changes to google-services(2).json(for example), so please remove (2) from the file name or rename it to google-services.json)
You will see the following screen.
Here the first block contains the classpath that you have to add into your project level build.gradle file under the dependencies section. The second section contains a plugin and dependencies that you have to add it into your project app-level build.gradle file. Please add these lines properly and carefully if you are adding them for the first time.
6. Now you should restart your application (NOTE: Please refer full restart not hot reload). Wait for few seconds and your application will be successfully added with firebase. If you see the bellow screen on your firebase then you have successfully added firebase to your app…
Congratulation…
Installing the required package
Update your pubspec.yaml with the following dependency.
This method triggers the signOut method to signOut the user.
Authentication using Email and Password
: Setting up the variables
final TextEditingController _emailController = TextEditingController(); final TextEditingController _passwordController = TextEditingController(); final FirebaseAuth _auth = FirebaseAuth.instance;
NOTE: FirebaseAuth is the entry point of the FirebaseAuthenticationSDK.
sendPasswordResetEmail() method triggers the Firebase Authentication backend to send a password reset email to the given email address, which must correspond to an existing user of your app.
If it is unsuccessful then it gives error:
ERROR_INVALID_EMAIL — If the email address is malformed.
ERROR_USER_NOT_FOUND — If there is no user corresponding to the given email address.
NOTE: Do not forget to add the callback URLs. You need to add three callback URL
for android:twittersdk: //,
for ios: twitterkit-CONSUMERKEY: //
add the URL that you get while enabling the twitter authentication from firebase.
You can add URL only for ios or for android.
3. Enable twitter sign-in option in the firebase console. (Paste the consumerKey, consumerSecretin the API key and API secret section respectively)
3. Click enable
We are now ready to go
: FirebaseAuth instance
Let’s create a firebase auth instance.
FirebaseAuth _auth = FirebaseAuth.instance;
: TwitterLogin
flutter_twitter_login provides us TwitterLogin class that takes consumerKey and consumerSecret that we got during creating the twitter developer account.
final TwitterLogin twitterLogin = new TwitterLogin( consumerKey: 'YOUR CONSUMERKEY', consumerSecret: 'YOUR SECRETKEY', );
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, 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!.
Login has become one of the most important parts of lives for a developer by having a working on-boarding system we can help tend to users need better than ever. hence why it has become a necessity in almost all the apps.
Because of This most companies have brought out a way for users to login seamlessly through their own apps companies like Facebook, Google and Twitter have made it so that u can log in in 1 click, and with flutter, It has become even simpler to implement.
What you will need?
A couple of packages from pub.dev, enable Facebook for developers and Twitter for Developers.
Packages are:
flutter_facebook_login: ^latest version http: any
What we are going to do?
How to access the required data of user through Facebook
Before we can just start logging in there are a few steps that are required to do for logging in Facebook.
Facebook :
So first of all you will have to enable Facebook for developers that is the only way for you to get access to your app ID and app secret, if you have a Facebook profile then it only takes a minute to do it.
After making an account make an app in Facebook for developers after which you will get access to your app ID and app Secret (to reveal app secret go into settings then basic it should look like this:
All the information required to make the sign In happen is in here
3. Now that we have created Facebook for developer’s profiles and have gotten access to our secret key and app ID we can move over to Firebase project to take the necessary steps for log in.
4. Ok once you are at the firebase project you can go to Authentication and then select sign-in methods.
4. Select the Facebook option, it will ask for your App ID and App secret the one you got from Facebook for developers.
5. This will help you in Signing In with Facebook and after that you need to copy that O’auth http link cause it is very important(save it in a text file)
6. Now you will need to go to https://developers.facebook.com/docs/facebook-login/android, to take other actions that will enable you to Sign In through Facebook(Not much left just 3–4 more steps). Don’t worry we are here for full support and will guide you through them as well.
7. Since we are not working with native android we can actually skip many of those steps(GOD I LOVE HOW EASY FLUTTER MAKES EVERYTHING ELSE), we can start at step 1 and choose our project name(the one we just created in Facebook for developers. So go ahead and select it
Choose your app you want to enable facebook login for
8. After selecting it we can jump directly to step 5, now there you will need to provide your app’s package name and main activity name there you can find them if you go through your app-level module and opening src t find AndroidManifest.xml (the path is android/app/src/main/AndroidManifest.xml)
Enter your package name and main activity in both fields
9. Now we come to the part that took me the longest and was very troublesome (don’t worry I went through the pain so you guys don’t have to!), so we come to Step 6 where now we need to provide release key for this,
so the things you will need to generate a release are(unless you have your app published on Play Store you will get your release key in SHa1 from there but you will have to convert it to base64 which you can do by a simple google search)
remember to fill in your own details in the command like your username and the path to open SSL (if you followed what I have said completely then it will be : “C:/open SSL/bin/OpenSSL” fill it in both places where it is required.
It will then generate the key required to for logging in to Facebook, it will be of 28 characters minimum and will end with an “=”
the release key should be added there
10. Now we are really close to completing our Facebook login all we need right now is to put our O’auth(remember this guy from step 5?), all you need to do now is go back to your Facebook for developers(the one where you created your app) and then you will see product + icon there click it.
after clicking on product and doing the additional steps you will have facebook login option there
After getting facebook login option there you can click it then select settings and then you will encounter this page:
See the censored part? That’s where you will have to put in your O’auth you got from Firebase(in case you didn’t save it you can go back and click on edit option in Firebase Sign in methods to get it again)
After that save changes.
11. Now we can finally move onto our project and add some configuration there as well
Go to your /android/app/src/main/res/values/ and find if you have a Strings.xml file if you dont have it create one, after creating one you can enter this information in it :
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">Your App Name here.</string>
<!-- Replace "000000000000" with your Facebook App ID here. --> <string name="facebook_app_id">YOUR APP ID HERE</string>
<!-- Replace "000000000000" with your Facebook App ID here. **NOTE**: The scheme needs to start with `fb` and then your ID. --> <string name="fb_login_protocol_scheme">fbYOUR APP ID</string> </resources>
DO as told in the comments.
Now go over to your <your project root>/android/app/src/main/AndroidManifest.xml and add the following just above the “<! — Don’t delete the meta-data below.” comment in androidManifest.xml file then add the following
After you are done with that part, you are almost good to go(there are some specific IOS configurations which you can find in https://pub.dev/packages/flutter_facebook_login be sure to do them as well if you want it to work for IOS as well)
Now in your project make a HelperClass called Authentication.dart
In the file you need to make a function that will help you sign the user into Facebook :
first of all import all these files
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter_facebook_login/flutter_facebook_login.dart'; import 'package:flutter_twitter_login/flutter_twitter_login.dart'; import 'package:http/http.dart' as http;
After this make an object of FacebookLogin() and write the following function
final fbLogin = FacebookLogin();
Future signInFB() async { final FacebookLoginResult result = await fbLogin.logIn(["email"]); final String token = result.accessToken.token; final response = await http.get('https://graph.facebook.com/v2.12/me?fields=name,first_name,last_name,email&access_token=${token}'); final profile = jsonDecode(response.body); print(profile);
return profile; }
After that, you can call that function in your button like
Congratulations you have achieved Facebook login, now on your app after clicking on sign In FB button you will be redirected to Facebook page to allow sign in and after allowing in you can see it print users data which you can store in your database and then log them in.
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, 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.
As a flutter developer, you have at least once come across a question of how would you draw a line between Stateless and Stateful, either this question would have been thrown on you or it has hit your mind hard by self-realization. However, it does not matter from where you get stuck here but the main point is….. Do you have any answer to it ?
Of course in search of this mysterious question, you would find that self-proclaimed complete definition on google which is…
If a widget can change — when a user interacts with it, for example — it’s stateful. A stateless widget never changes. Icon , IconButton , and Text are examples of stateless widgets. … A widget’s state is stored in a State object, separating the widget’s state from its appearance.
But if you have ever been a part of a discussion or have appeared for an interview (like me) then you must be aware that the conversation over stateless and stateful does not end here.
whaaatttt… ???? yes, the conversation does not end here.
After giving this definition a question arrives if the stateless widget has a stateful child what it would be called? Does it become a stateful widget or how it manages itself?
So….In the layout, if we choose there can be different widgets like a container which we will select as a stateless widget and it’s child also a container but we will take as a stateful widget and when you would rebuild then the state will only affect stateful container so it does not matter if the parent widget is stateful or not if the child is a stateful widget.
Actually you can say
The only thing which makes them different is the ability to reload at the run time
But the conversation does not end here
so let’s take another definition to conquer the dilemma
The important thing to note here is at the core both Stateless and Stateful widgets behave the same. They rebuild every frame, the difference is the StatefulWidget has a State object which stores state data across frames and restores it.
If you are in doubt, then always remember this rule: If a widget changes (the user interacts with it, for example) it’s stateful. However, if a child is reacting to change, the containing parent can still be a Stateless widget if the parent doesn’t react to change.
That effort was from my side but a description is not fully completed until we don’t know the view of others so let’s have some thoughts :
In this video, a simple definition of stateful and stateless is given
Stateless is Data less and Stateful is Data full
In this video, things have described in some interesting way so first, you should know what is the state
State The state is the information that can read synchronously when the widget is built and might change during the lifetime of the widget and that state changing requirement defines if the widget is stateful or stateless.
Incidentally, the difference between the stateful and stateless widget is very limited, the stateless widget can only once on to the screen while a stateful widget can be drawn multiple times.
Which effectively means that the build function of the stateless widget can be called only once when the class is instantiated or an object is created while in stateful widget build function can be called multiple time during run time and it also states that the content in stateless is immutable while in stateful it is mutable.
The build(…) function of the StateLessWidget is called only ONCE. To redraw the StatelessWidget, we need to create a new instance of the Widget.
After reading that much of content now must b able to create your own analogy which might help you to create your own way of explaining things completely with ease.
So this was the discussion that could help you to find your at the stage where at least you can have an explanation for the question which is generally asked during the conversation or that is asked to check one’s root knowledge.
There might be some aspects which I forgot to explain but as soon as I get to know I would try my fullest to update and as you know that this conversation began from widgets and it should go further to with different topics of flutter or as a series and in the next topic we would come with some new fundamental things.
Thanks for reading this article if you find anything that could be improved please let me know, I would love to improve.💙
If this article has helped you a bit and found interesting please clap!👏
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, 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!.
The Interactivity in Flutter just became 100 times better with the new widget called — Interactive Viewer, released in Flutter version 1.20, It immediately became the one thing everyone fell in love with(yes, including me.)
So, What does the widget do ?
By wrapping up your widgets in Interactive Viewer you can do actions such as drag, drop, zoom etc. with your widgets and not only that but with the introduction of Flutter version 1.20 the drag and drop capabilities have became even more polished.
An example of what this widget is capable of :
zoom and drag just by wrapping the image with one widget
Now, lets talk about how it works:
1. Lets take an image and save it in the assets folder.
2.Now add that image to the pubsepc.yaml file:
assets: - assets/tiger.jfif
3. after that we can use the image in our app like this
One of the best and most used properties of this widget would be maxScale, it represents how much you can stretch the image.It takes the value of double in it.
with this you will be able to stretch it 5 times more than what you were able to before, this property helps us to set how much stretch should be allowed on an image.
2. minScale
This property works opposite to maxScale, however it take a double value as well. It represents how much you can squeeze an image.
After assigning it you can do something like reverting the image back to its original position after user is done stretching it, so for that we will use onInteractionEnd with the controller
Before we start, first you need to know that controller can access a special property called “value” which is of type Matrix4
(You might Need to research about matrices before diving straight into using them)
Now we can change the controller’s value inside onInteractionEnd like this
controller.value = Matrix4.identity();
Now what is Matrix4.identity()? Well its basically an identity matrix
Identity Matrix is this :
identity matrix
Now what it does it that it returns the controller to its original value, and that’s what our aim is to return the image to its normal size after user is done transforming it.
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, 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!.
In this article, we will explore the Date and Time Picker in a flutter. We will not be using any package in this application. We will use some core functions available in flutter to achieve this. We will implement a demo of theDate and Time Picker in your flutter applications.
A date and time picker for a flutter, you can choose date/time / date&time in English, Dutch, and any other language you will want, and you can also custom your own picker content.
Demo Module ::
Demo.gif
Code Implementation
Create a new dart file called DateTimePicker.dart inside the lib folder.
In this screen, You will be able to choose the date and time by tapping on them in your Application.
In this article, I have explained a date time picker demo, you can modify and experiment according to your own, this little introduction was from the date time picker from our side.
I hope this blog helps will provide you with sufficient information in Trying up the Date Time Picker in your flutter project. 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.
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, 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 article will walk you through the basics of file I/O and in the end, You will be able to build your own storage service just like shared preference using Dart: IO library.
Our main aim is to dig deep into Flutter file I/O so for that, we are creating our own shared preferences just to learn the basics of file I/O.
Shared preferences in flutter allow the developer to store some sort of state weather it’s related to user data like the day-night theme or some app-level data which we want to persist even after closing the app.
Let’s start by jumping straight into our Database Code for Complete Code along with UI checkout the above git repository.
//Function to get all the data in json format Future<Map> getData({String key}) async { File tempFile = await _localFile; if (await tempFile.exists()) { return json.decode(tempFile.readAsStringSync()); } else return null; }
//To delete data if exist in the file Future deleteData( String dataToDelete, Function onDelte, Function ifNotExist) async { File tempFile = await _localFile; if (!tempFile.existsSync()) { ifNotExist(); } else { Map data = json.decode(tempFile.readAsStringSync()); var result = data.remove(dataToDelete); if (result == null) { ifNotExist(); } else { tempFile.writeAsStringSync(json.encode(data)); onDelte(); } } } }
In the above code we are Interacting with files on our device using dart.io library the above code replicates the same functionality of shared Preferences.
Let’s take a look at each and every function one by one :
localPath() : In localpath() we are accessing document directory using path provider package by calling getApplicationDocumentsDirectory(); method. This function returns a path of type string, we will be using this path for storing our Database file.
localFile(): Now as we got our path from localPath() , We are now creating a file of type JSON using the path we got from localPath() and returning a File as an output return File(‘$path/preference.json’);
writeData(): In this, we are first storing the file reference in a file variable File file = await _localFile; now we can access the same file, Now we create a temporary map and store the JSON file in it by parsing it using json.decode() tempMap = json.decode(file.readAsStringSync()); , After that, we add the new map to the tempMap variable using tempMap.addAll(data); now we right back the updated data by using json.Encode file.writeAsStringSync(json.encode( tempMap));
getData(): This function returns a future Map if the file exist this function returns all the data present in the file by calling json.decode(tempFile.readAsStringSync()); .
deleteData(): It takes three-parameter, Last two parameters (onDelete,ifNotExist) is called when the file got successfully deleted or when the file doesn’t exist. The first parameter takes a key of type string and removes that key-value pair if it exists using data.remove(dataToDelete); , This function (data.remove( )) returns null if the file dosent exist and returns the value if it exist .
Conclusion
In this article we learned how to do basic file I/O operations in flutter and alongside we also learned how to parse JSON file using dart: convert library and accessing the device storage using path_provider package. Now go on and create your own file storage system or customize it as per your need ,Sky is the limit 🙃🙃🙃.
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, 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!.
Google, the search giant recently rolled out the new stable version of its Extensive Popular Cross-Platform UI Framework Flutter.
Flutter 1.20 & Dart 2.9 have been released simultaneously this time with apparently Substantial Performance Improvements from their contemporary releases . Flutter is now equipped for building apps for iOS, Android, Fuchsia, web & Desktop with new platform support on talks with Ubuntu for Linux apps, Microsoft’s Android Surface Duo, and Windows 10X devices will also be soon available.
Some Prominent advancements are Reduced size & Latency, less janky starting animations, and faster handling of UTF-8 strings, mouse cursor support, new widgets like Interactive viewer making pan, zoom & drag-n-drop easier, range slider & date picker revamped, newly flutter browser variant of dart dev tools, and its embedding in the new VS Code extension keeping all in one window frame for better debugging, Integrating flutter to the existing app made convenient with Pigeon, improved support for Metal on iOS, and new Material widgets.
4 Main Pillar Improvements this release mainly focusses are :
4 main pillar flutter release is focussed on
There is a lot in the release and a lot is yet to come but to sum it up in a Blog
Some of the Key Announcements In Release are ::>
Interactive Viewer : Newly Added Widget
The interactive Viewer widget is Added In the Newly Update providing flutter the Ability to Enable Pan, Resize, Zoom & Drag-n-Drop like Simple Interactions in Flutter Apps.
To Learn How To Embed Your Apps with the Interactive Viewer Widget Checkout the Flutter API documentation :
A New Similar Kind of update release is the newly added specific target ability to the Drag ’n’ drop making It precisedemonstrated in the example below :
One of the Most Highly Anticipated Release update among the Developer Community is text autofill support in flutter apps. With Flutter 1.20, Flutter has added the basic autofill functionality so that — no further need to re-enter data already gathered by OS.
Autofill Support for Web Apps is also on the Further Updates lined-up
Mobile Autofill Support In Flutter Apps
Slider & Range Slider Update
Slider and RangeSlider have been updated in the newly version keeping in sync with the Material guidelines.
New Discrete SliderWith Value Indicator
Check Out the Medium Article to Know About All New In Sliders :
A Command Line Tool Pigeon, at which the messaging protocol is defined in a subset of Dart which then generates messaging code for Android or iOS forming the communication between the two — Flutter & Host Platform safer and easier for pluginsandAdd-to-App is developed for Platform Interops.
Pigeon example
Pigeon file:
import 'package:pigeon/pigeon.dart';
class SearchRequest { String query; }
class SearchReply { String result; }
@HostApi() abstract class Api { SearchReply search(SearchRequest request); }
Though Pigeon is still in the Pre-Release phase, You can Try it out In Your Projects with the Documentation & Sample Project Lending you a Helping Hand.
Make your apps more stable and performant with Dart’s null safety. Sound null safety is a distinctive feature of Dart that helps you write less error-prone code and get better performance.
Dart is a type-safe language. This means that when you get a variable of some type, the compiler can guarantee that it is of that type. But type safety by itself doesn’t guarantee that the variable is not null.
The null safety feature makes this problem go away:
Try out the Null Safety Enable Dartpad to check the features : —
Check the following Github Project for Flutter Framework itself. This metadata is used for the Android studio, IntelliJ & VS Code Extensions by the flutter Team and Possibly by tool builders
:: Cupertino Icons and Colors are now rendered, Improved Outlines, performance fix for tree-shake-icons, Mouse Cursor Support, Improved Debug Discoverability in VS Code.
Unsupported Platforms Update: The flutter project will show enable option for Unsupported platforms.
Improved handling of Unsupported platforms
:: New Pubspec Format — New Pubspec format is required for further Updating | New Plugin Development as the old formats Inability Specifying platform Support for Plugins.
Check Out The NewPubspec.yamlformat required for publishing new/update Plugins :
Note: All Existing Plugins with the Old Pubspec format will Continue to work in the Existing future Without any Hindrance.
Closing Thoughts
Flutter 1.20 — Apparently Described as the biggest release in the Flutter history. The update release has created an igniting spark among the mobile developer’s Community by focussing well on varied Important Aspects.
Though Each New Release Certainly Brings with In Increased usage and momentum Which can be easily seen that the number of Flutter apps in play store reached from an astonishingly 50k to 90k in the span of mere 3 months. Also, Flutter being well supported by the Dart which has now moved up further to the #12 in the top 50 languages: reported by IEEE
What makes it more special for us is that Our Country, India now being the #1 region for Flutter developers, having doubled in the last six months
Much More Yet To Come:Enhanced Null Support, a new version of the Ads, Maps, and WebView plugins & Tooling Updates.
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, 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.