Skip to main content

Why Flutter?

· 6 min read
Luke Walton
Zeta Developer

A few years ago, my team faced a challenge - deciding the right framework to use for mobile development going forward. While our team had focused on native Android in the past, the need for cross-platform development was imminent; we had to decide on the path forward.

Ultimately, we decided that a cross-platform framework was needed.

We saw two main approaches: the 'easy way' and the 'hard way'. The 'easy way' involved shipping a web app (HTML, JavaScript, CSS) with some extra APIs to connect to native components; this approach is taken by Ionic, Cordova and others. This approach works for a lot of use cases and gets an app out the door quickly. The 'hard way,' on the other hand, is compiling some other language into native code – a bit closer to the metal, but requiring someone to build out that entire toolchain. As we looked forward, React Native and Flutter emerged as the two big modern players in cross-platform app development. Let me walk you through our decision, and importantly, why we chose Flutter.

Dart vs TypeScript / JavaScript.

As web developers, many of us are indeed familiar with JavaScript, and some will also have experience with TypeScript. While this familiarity can be a huge benefit for adopting frameworks like React Native, it also means inheriting some of JavaScript's inherent characteristics. In contrast, Flutter is powered by Dart, a language that significantly transforms the development process and app performance.

Typing System and runtime safety

  • React Native relies on JavaScript, a dynamically typed language. Optionally, TypeScript adds a layer of static typing, but the dynamic nature of JS means that quirks and unexpected issues can still arise at runtime. Types are checked at transpile time in TypeScript, but if types are omitted or changed, it can still lead to runtime issues.
  • Flutter uses Dart, a statically typed language. This offers runtime safety, helping avoid silly errors. Dart also incorporates sound null checks, guaranteeing that null exceptions should not occur at runtime if best practices are followed. This effectively forces developers to proactively consider and handle potential null variables, leading to more robust code. A significant portion of this comes down to personal preference. As a developer coming from Java and other object oriented languages, the syntax and format of Dart code appeals to me. Further, Dart has its any equivalent with dynamic, which for many cases is essential.

Compilation and Performance

  • React Native uses actual native UI components during compilation. This requires a 'bridge' to allow the connection from JS to Native. This can decrease performance, although this is often negligible, and cause unexpected behaviours when building between different platforms.
  • Flutter code is compiled directly ahead of time to native machine code (or JS / WASM for the web). This direct compilation eliminates the need for a bridge, ensuring fast startup times, smooth performance, and an optimised user experience on any device. As Flutter does not use any native UI, it can be compared to a game engine, building out the entire app itself, which can give better results for more complex UIs. In practice, both platforms now offer comparable performance for many use cases, thanks to significant improvements in recent years.

Developer Experience

  • React Native should be easier for developers to get started, as it utilises many tools web developers are already familiar with. We found the initial setup to be more difficult than expected, and there were teething issues during our initial testing. Once setup, the process of building an app should be very familiar to existing web developers, especially those with React experience.
  • Flutter should have been more difficult to get started with, owing to the new language required in Dart. But familiarity with other object oriented languages, and the comprehensive guides provided by flutter.dev made the experience easy. The developer tooling within VSCode and Android Studio / IntelliJ is exceptional and incredibly powerful for both frontend and full stack development. Another factor is Flutter's declarative UI. This had the potential to be a challenge, but our team quickly adapted and found building UI in Dart beneficial, as we do not need to consider separate languages for logic, content and design and it can integrate well with state. Both platforms offer a hot reload feature, allowing changes to appear instantly during development, which is a huge benefit over older platforms.

Challenges with Flutter

While our experience with Flutter has been positive, it is important to acknowledge a few limitations that we have encountered. Larger app sizes are inevitable, as each apps ships with it's own Flutter engine. There are also cases where packages either do not exist, or are less mature compared to their npm equivalents. Despite these challenges, we have found that for us the benefits outweigh the drawbacks.

Conclusion

With all these factors in mind, there is very little to separate these frameworks. Both are rightfully popular, and have many success stories. For teams deeply invested in React or reliant on packages exclusive to React, React Native would likely be the obvious choice.

The key factor in our decision to use Flutter was the developer experience. Right from our first interaction with Flutter, our team was enjoying the work. As one colleague succinctly put it: "Why Flutter? Because it's fun".


Epilogue

This post's content is derived from a talk I delivered at Zebra DevCon in 2023; watch here. In the years since, my appreciation for Flutter has only grown, reinforced by its continuous evolution and growing adoption. The framework's commitment to improvement is evident in its quarterly releases, each bringing significant performance uplifts. Flutter has truly matured from a promising new option into a production-ready framework suitable for a wide range of products. We have used Flutter for multiple enterprise applications and it has proven to be performant, reliable and enjoyable.

Technical merits are only part of why we continue to use Flutter, and we have been continually impressed by the Flutter community. The breadth of resources, from comprehensive documentation to high-quality open-source packages, has made it easy to find solutions and continue building. The community's willingness to collaborate and share knowledge, both in person and online, is invaluable and has greatly accelerated our learning and problem-solving as a team.