Why Flutter Might Be the Best of Both Worlds

A little more than a year ago, I started working on my first project with native mobile applications. It has been wonderful learning the intricacies of the iOS and Android platforms, but I’ve noticed how cumbersome it is for a team to maintain two versions of the same application.

It takes quite a bit of overhead to verify that the applications have feature parity, adequate test coverage, and any image/text changes (don’t even get me started on localizations). This overhead tends to slow down a development team, but the benefits of native performance surely make up for it in the end… right?

What Cross-Platform Lacks

If you don’t need native performance, you’re better off saving development time by choosing one of the available cross-platform frameworks like React Native, Ionic, or Xamarin. Each of these frameworks has advantages and disadvantages, but they all consist of the same architecture: a shared layer of business logic with some type of abstraction for the UI layer that converts the template from the framework into the native UI elements.

The shared business logic is excellent, but I notice a lot of issues with the abstraction of the UI layer, especially after major updates to the operating system.

This begs the question: What if we didn’t have to worry about a UI abstraction? What if we could guarantee that our app would look the same across platforms and OS versions?

It is possible with the help of Google’s new cross-platform framework, Flutter.

What is Flutter?

Flutter is Google’s open-source, cross-platform framework for building mobile applications. Much like the other cross-platform frameworks I mentioned, Flutter provides a mechanism for a development team to maintain a single codebase while building two mobile applications (iOS and Android). Flutter isn’t just an SDK for iOS and Android development; it’s a portable UI toolkit that can be run in a variety of platforms.

It ships with the lightweight and wicked-fast Skia Graphics Library, which means it is responsible for rendering any and all pixels on the screen while your app is open. Flutter has no UI abstraction. It renders the entire UI layer and removes any limitations that the platform or OS version may have imposed on you.

Flutter is written with the Dart programming language, which was originally designed by Google as the next language for the web. Dart compiles to ARM and x86 code with the help of a JIT compiler and supports asynchronous programming. It is object-oriented, and the syntax is fairly straightforward, so anyone familiar enough with C# or Java should be able to learn it rather quickly.

So how does Flutter stack up to writing native applications or other cross-platform frameworks?

Flutter vs. Native

I already highlighted some of the pros/cons of writing native apps vs. using a cross-platform framework, but how is Flutter different?

The main appeal for writing native applications is performance. Native apps are faster than most cross-platform frameworks for two reasons. They don’t have to worry about a UI abstraction, and the business logic is optimized for the language of the platform.

Flutter challenges this claim that cross-platform isn’t as fast as native by handling all of the rendering of the UI. As I mentioned previously, the Skia Graphics Library is fast. If your phone’s hardware supports rendering the screen at 60 frames per second, Flutter will render at 60 frames per second. Also, since Dart compiles to ARM and x86 code, it is surprisingly fast—not as fast as optimized native code, but fast enough to close a sizable gap compared to some of the other cross-platform options.

Flutter vs. Other Cross-Platform Frameworks

The main benefit of choosing a cross-platform framework over native applications is the amount of time spent developing and iterating on new features. Many of the tools and enhancements from web development have started to make their way to mobile through React Native and some of the other cross-platform frameworks. React Native has benefitted from React, while Xamarin has benefitted from the recent enhancements to ASP.Net Core MVC.

Flutter wasn’t designed as a framework specifically for mobile development. It’s Google’s portable UI toolkit that can be run on a variety of form factors. Because of this, it doesn’t have to worry about the constraints that are typically imposed by the mobile platform.

In addition to this, the Dart programming language allows for stateful, hot reloading as you make changes to the code. Android has this functionality if you’re making changes to the XML template for a fragment, but if any changes are necessary to rebuild the project, you will need to start from scratch. Since the UI of a Flutter app is entirely built with Dart, this stateful, hot reloading is always available as you make changes to any part of the Flutter app.

Should I Be Using Flutter?

Choosing the right technology for the job is difficult, and the addition of more options tends to make things more complex. There’s a form of analysis paralysis involved with the number of cross-platform options. I can’t say whether or not you should be using Flutter for your next mobile app, but I can at least motivate you to give it a try by checking out The Flutter “Getting Started” Guide.

I would love to hear your thoughts on Flutter and Dart! Do you think it has a chance to be the most popular cross-platform framework in the next few years?

Additional Resources