By WalkingTree June 19, 2020
Most of the time when we start a new Flutter project there’s this single line of code that we don’t have to change. That code starts the Flutter app and makes sure to show it to the user.
Void main() => runApp(MyApp());
The main function will run the MyApp() constructor, like any other programming language where the main function is the entry point to start an application. Although this function runs perfectly, we may come across some issues in projects which are more complex:
- The command will only run the MyApp widget without any arguments, but what if you want a completely different backend environment to be called, or what if there are other versions of the app which you want to test and deploy?
- What to do if you want to check the user preferences like theme, language, etc. before the application runs? Or how to check whether the user has logged in or not, in order to show the correct screen?
- Lastly, what if there’s an error in the application? How to show the error screen to the user for reporting the error?
Let’s take a look at the main function and possible solutions for the above questions.
Managing different app versions – There are many reasons to have different versions of an application, from different backend environments to different branding. Whatever the case might be, you will have to instruct Flutter on what to display or change in the app without creating separate projects for each app. You can build Flutter apps via the $ flutter run command. But how will MyApp widget know that you are running different versions? The way is to create a configuration for each file with a config data class.
Read on to progress on this topic.
In recent times, due to the effects of the pandemic, a mask detecting app is in great need….
Theming is styling an application so that its look and feel matches your personal design aesthetic or that…
In this blog, we have collated the important Flutter best practices that should be kept in mind for…
In the last blog and webinar on State Management in Flutter, we learned about managing state using Stateful…
In this week’s blog on plugins, we will look at a very special requirement – OCR(Optical Character Recognition)…