My experience with Flutter and Dart

António Valente
Oct 10, 2018 · 5 min read

As an Android developer I have always been fascinated by the hybrid mobile app development world. Developing an app for both Android and iOS with one codebase is like a dream come true! You don’t have to deal with all the hassle of maintaining two different projects, and you don’t need to learn how to develop apps for Android and iOS which will take you quite some time.

That’s why I was always an early adopter of these kind of frameworks. I’ve already got my hands on Ionic, but since I’m coming from Android and had no real experience with web development, it was a bit difficult for me to learn and keep myself interested to actually invest time on it. That was a disappointing experience for me and since, almost all of these kind of solutions are web based, I lost my interest. At least until Google announced Flutter.

Flutter is different from other approaches to hybrid app development, and that’s mainly because it uses Dart.

  • Dart is really easy to learn. It feels very familiar and it’s syntax is clear and concise.
  • Dart is compiled “ahead of time” (AOT) into native code for multiple platforms, eliminating the need for a JavaScript bridge (like Ionic or React Native) and improving performance.
  • The Hot Reload feature lets you quickly and easily experiment your code and see the effects of your changes without waiting for the app to build, allowing you to be more productive.
  • Everything’s a widget, and each one of them is an immutable declaration of part of the UI. Unlike other frameworks that separate views, layouts and other properties.
  • It comes with a rich set of widgets for both Android and iOS to match the look and feel of native widgets, which can be easily tweaked and customized.

These are some of the reasons that made me interested on Flutter right away. And since, at Coletiv we are always encouraged to learn and try new things, I quickly did an experiment with Flutter.

Flutter might be the solution we needed to develop proper apps with one codebase, and that’s mainly because it uses Dart.

The app idea

The idea was pretty simple. In Portugal there’s an app to pay for your parking sessions, but those sessions only last up to 2 hours. Which means that every time you need to leave your car parked for longer than 2 hours, you have to manually renew your parking sessions. That’s annoying!!! Besides, if you forget to do so you are greeted with a fine in your windshield.

So we though: “Why not build an app that renews your parking session automatically until the time you specify it to do so?” and Flutter seemed the perfect solution for it, at least on paper.

We wanted the app to be available for both Android and iOS and we wanted to do it fast, since this was only an experiment.

In less than a week, we developed a functional app with the bare minimum necessary to allow users to setup parking sessions (check our Github). But once we tried to renew those sessions automatically on the background, Flutter started to reveal some lacking features and quickly reminded me that it’s only now getting ready for his first 1.0 release.

In less than a week, we developed a functional app with the bare minimum necessary to allow users to setup parking sessions. That reveals how productive you can be with Flutter.

What went wrong

There is no easy way to execute Dart code on the background of your Flutter app (check this issue). It is possible to do so using platform channels, but that would require you to do platform specific code for Android an iOS and that kind of defeats the purpose of using Flutter in a project (if you want to know more about this I recommend you to read this article).

There is a plugin developed by the Flutter team available for Android, the Android Alarm Manager plugin. It allows to schedule and run background code on Android using the Alarm Manager but even that has problems like this one. On the iOS side there is not yet a solution to this issue, at least to my knowledge.

We can’t expect the Flutter team to do in one year what took Android and iOS ten years.

Final thoughts

I think that a feature like running code in the background is really important and should be easily accessible to us developers on Flutter SDK. Instead, at least at this point, the Flutter team is kind of giving us the tools to do this on our own and hoping that the community contributes with plugins to enable the execution of background code.

And you know what? We can’t judge them for that! We might think that since Google is backing Flutter they are obliged to do better, but in reality the Flutter team is not that big and we can’t expect them to do in one year what took Android and iOS ten years. And since Flutter and Dart are completely open source, let’s just be glad for it and try to contribute whenever we can to make these awesome projects better.

Source code

The source code for this project can be found in here.


Thank you for reading! 😄

I hope that my experience was useful to you somehow. If you’re interested in giving Flutter a go, you can get started here. Also don’t forget to read the Dart language tour to help you understand how Dart works.

Thank you so much for reading and if you enjoyed this article make sure to hit that 👏👏 button. It means a lot to us! Also don’t forget to follow Coletiv on Medium, Twitter, and LinkedIn as we keep posting more and more interesting articles on multiple technologies.

In case you don’t know, Coletiv is a software development studio from Porto specialised in Elixir, iOS, and Android app development. But we do all kinds of stuff. We take care of UX/UI design, web development, and even security for you.

So, let’s craft something together?

Coletiv

Thoughts, dreams and rants about technology and work life from the Coletiv team

Thanks to Tiago Duarte and Priscila K..

António Valente

Written by

Coletiv

Coletiv

Thoughts, dreams and rants about technology and work life from the Coletiv team