fbpx

Introduction to Flutter

Introduction to Flutter by Kurt Lourens

Flutter is a relatively recent addition to cross-platform mobile app development frameworks. It is a Google product, open source, and has a very strong and growing community. If you’re not too familiar with Flutter, the below will cover how it works, and the pros and cons of using it.  

Due to its relatively short existence, it changes often and sometimes drastically. An example of this is the recent Flutter for Web and Flutter Desktop Embedding that have become available. This makes Flutter exciting to try out, but also risky. Since Flutter is a Google product it is also vulnerable to being ended sooner than its users would like. The Google Cemetery has a long list of products that Google has ended. 

THE BASIC IDEA

Flutter Apps are written in Dart (another Google product). Dart is a C-like language that is relatively new, and is receiving a lot of the features that other languages have had for decades, such as the recent extension methods addition.  

The Dart code in Flutter Apps are Ahead-of-Time compiled in release mode and Just-in-Time compiled when in debug mode – which leads to a better development experience and better speed in production. 

Flutter App’s views are similar to that of React. Instead of components, Dart calls it widgets. React has components and functional componentsand Dart has stateful and stateless widgets. The Dart code interacts with the Flutter Engine, telling it how and what to draw on screen, and the Flutter Engine communicates with the platform it is running on. Therefore the Flutter Engine is a sort of Virtual Machine.  

If your Dart code works on the Flutter Engine, it will also work on any platform that can run the Flutter Engine. This strategy is what lead to Flutter for Web and Flutter Desktop Embedding materialise in such a short period. 

SOME CAVEATS

You may be thinking that you will only need to write Dart code and the Flutter framework handles the rest. However, the ecosystem is not 100% there yet.  

In a lot of situations the app developer will need to change something that is platform-specific (i.e. changing the app Icon.) For Android, changing an app icon involves working with its resources folder and the manifest file, but for Desktop it involves changing a .ico file. 

You would also still need to deal with the app stores. Each app store has their own set of requirements and rules that they expect developers to follow. And Apple is by far the most expensive and most strict. 

FEATURES

Flutter’s developer environment is all about speed. The hot reloading means that your changes are reflected within a second or two while maintaining the app’s state.  

There are also a few ‘hacks’ that make development even faster. When building the Android app, it can take a few minutes to get to the hot reloading phase, because the emulator needs to launch and the app needs to be loaded onto the emulator.  

Something that a few users have started doing (myself included), is developing the app in Desktop mode. This opens a simple window on your Windows, Linux or Mac machine capable of running your app within a few seconds. The best part of this is that you can resize the window to emulate different screen sizes. 

ISSUES

Flutter is very new and has had a few issues in the last year or two. Currently there is a huge issue with Flutter crashing on certain Huawei phonesIt is likely that Flutter will have more issues similar to this until it is more mature. 

IS IT WORTH IT?

I would definitely say it is worth looking into for personal projects or small projects that require an Android and iOS app. However, it would be difficult convince clients to trade more stable and reliable cross-platform frameworks for fancy, fast-paced development 

A lot of the issues mentioned can be picked early with proper testing and releases to Alpha and Beta channels. 

I have used Flutter to create an app that is live onGoogle Play and theApple App Store. I may be biased, but I am pleased that I didn’t have to learn Objective-C/Swift or have 2 different code bases doing the same thing just to have an iOS app.