flutter

One year with flutter

It’s been one year since I started using Flutter, and it was nothing less than a rollercoaster ride, considering all the things that happened around us. What fascinates me is that even Flutter has undergone a massive change in the past year and still is at the moment I’m writing. Flutter supports production-quality web and also is making deep inroads in other platforms. So for anyone who is contemplating whether to align their career with Flutter, just let me say- Go ahead!

The purpose of writing this blog is to shed some light on those who have just started this journey. I hope you will get some insight after reading this. Before flutter, I had some experience in native android development, so maybe that helps me grasp the concept quickly. Comparing it with native, flutter seems more user-friendly with less boilerplate code. So here are some tips that you can keep in mind while building an app in Flutter.

Flutter

Flutter Architecture:

There are several ways to design a flutter project architecture, and all those have their merits. But always keep two things in mind; Separate business logic from UI, and widget reusability. The purpose is to support scalability and to make your code clear to your team members. Bloc is an effective way to keep business logic aside, it can also be used to handle states of different widgets. Also, make sure to write UI components separately so that they can be used again elsewhere. This practice can help you in the long run.

State Management:

Flutter works on three concepts: Widget, Element, and RenderObject. An Element is an instantiation of a Widget at a particular location in the tree. RenderObject is what we see on the screen, which is painted based on the constraints and values given to the element. Flutter is declarative. It means that Flutter builds its user interface to reflect the current state of your app, so whenever the user makes changes to input or value associated with it, the state of the widget changes, which has to be rebuild.

State management can be done in several ways using provider, Bloc, redux, etc. The provider is the one that is endorsed by google itself. It’s much easier to handle, and there are multiple ways you can make good use of it like StreamProvider, MultiProvider, ChangeNotifierProvider.

Backend Integration:

Most of the applications are glorified API calls. All you have to do is display the data from the backend in a convenient way. The best practice would be to write a common method to route API calls. Dio library is an effective way to handle API calls. dio_cookie_managercookie_jar and dio_http_cache can be used to handle cookies and cache storage respectively. Data models required to handle JSON responses can be created using app.quicktype.io/.

Flexible Screen Size:

So when you convert a particular UI, make sure to test it across different screen sizes since there are chances that it might not show a consistent result. This issue can be avoided by defining a class called Config to which takes up the screen width and height of your device and calculates a block height and width, you can use this value instead of hardcoding the width and height of any widgets.

Bug Reporting:

If you are building a production-quality application, it is essential to integrate a platform to report the errors on your application. The most convenient method would be to add Firebase Crashlytics or Sentry so that in case an issue arises while the end-user is using your application, it can be logged and sent to this platform. Crashlytics can be used to notify if the app crashes, or you can programmatically call if exceptions arise. Note that it will only send the log back to your dashboard once the app crashes.

Version Controlling:

Talking about version control management there are two different things; one is to manage the flutter SDK version, which can be set differently for different projects. This can be done using Flutter Version Manager(FVM). FVM helps with the need for consistent app builds by allowing to reference Flutter SDK version used on a per-project basis. It also allows you to have multiple Flutter versions installed to quickly validate and test upcoming Flutter releases with your apps without waiting for Flutter installation every time.

Another thing is to manage app versioning. Since the app gets released in Playstore, it is important to provide proper updates at certain times, which can be managed without causing any inconvenience to the user through plugins like in_app_update. Also make sure to integrate GIT into your project and connect with cloud storage like Bitbucket, Github, etc.

1 thought on “One year with flutter”

  1. Pingback: Building bottom navigation bar with Micro-Interactions

Leave a Comment

Your email address will not be published.