Flutter Multiplatform : A Taste Test

First, congratulations for my self. I have develop Noa, a todo list, notes and expense tracker for Linux and Android. The reason Noa was created because my dissatified with many todo list available in PlayStore : ads, subscription and tracker.

Also developing one apps that able target my computer and phone, hopefully make them able sync (I hope in future), with single codebase is wonderfull for me.

Moving on, developing multiplatform apps pose some interesting challange such dealing with function that only available in one platform, inconsistencies in output and much more. I felt like building responsive web design with logic.

1. Platform-specific functions

When I happy able to run flutter's app in Linux, I thinking about what if push this forward into Android's platform. Fyi, I choose develop app in Linux because building native linux's executable way faster than for Android. So, when I push forward to compile for android, things happen.

The database driver I used in Linux was sqflite_comman_ffi which working by use foreign function interface from sqlite3 shared library that available in Linux's. Unfortunately, that not working same way in Android where the sqflite have more convinient aproach, so I installed both sqflite for Android (sqflite) and Linux (sqflite_comman_ffi).

Luckly, flutter have smooth way to detect what operating system you target:

import 'package:flutter/foundation.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';


late DatabaseFactory dbConn;

if (kIsWeb) {
    throw UnsupportedError('Platform not supported');
}else if(Platform.isLinux | Platform.isWindows){
    # use sqflite_common_ffi
    sqfliteFfiInit();
    
    dbConn = DatabaseService(databaseFactory: databaseFactoryFfi);
}else{
    # use sqflite
    dbConn = DatabaseService(databaseFactory: databaseFactory);
}

2. Display Inconsistency

Flutter undoubted works well in Android, and it is, the render was smooth and everything in place.

But that have different story for Linux. Flutter use libgtk-3.0 as foreign function interface, if my memory serve well. Sometime the color not rendered well such bottom navigation item color that blank white, the border of app window flickering, when resizing sometime display bug happend (but not always) such the border gone.

So I set window size limit for app that running in Linux (or any desktop system), to prevent unwanted things with UI.

3. Package ecosystem may not work well outside Android and iOS

Since flutter first designed for mobile apps, Android and iOS receive demographic bonuses such maintainable package, rich and diverse options of package.

Outside that, not so much. Package that not dealing will hardware or platform specific feature may safe to use when package that use platform-specific feature is out of luck (especially you need most!).

For example freeze and bloc works in logic space of application but Sqflite works with native system dependencies that varies in other platforms. shared_perference may only works in Android and iOS since that concept fit there (in Linux maybe plain file that hold key value in dotfile-like directory could works too).

4. Build preparations

Targeting a platform need plethora works to make sure compilation success, from gathering toolkit for targeting platform such compilers, setting up dependecies for those platform and compiling it.

If you used Linux-based operating system and targeting app for it, then you need flutter, build-essentials, libgtk-3.0 and something in between, call it a day. Simple.

For Android, we might need mighty Android Studio / Android commandtools if you not wanted Android Studio. Also, that bringing dependencies such Java Development Kit (JDK), Android SDK and much more. This crank up my space around ~3Gb (note: without Android Studio installed).

Also, there a lesson learn about JDK that do not take the NEWEST LTS, pick older second version of LTS because the tooling not supported with the latest LTS. This happend when I pick JDK 25 today and forced downgrade to JDK 21 due to incompatability with the Android projects.

My assumption is the release of LTS is just few time ago so the community need time to adopt the new LTS version.

5. Maintenance

Self-explanatory, I use couple package as dependecies, watching package to keeping it updated and works as it intended is not easy feat, especially the package that contain use of platform-specific function.

Luckly, devDepencies work in development machine so I no need worry it (of course, from its name development depencies not runtime/compile time dependencies so pose no other platform specific issues).

Conclusion

Flutter employ function-based widget to build UI (like JetPack Compose) rather XML UI design like common Android and GTK apps, which I found revolutionary because no need hassle with template and so forth yet ergonomic. And with that I could make single apps for mobile and computer, yet still not surpases the undefeatable web platform.

Flutter is awesome. It allow me develop multiplatform apps with my low-end laptops, also rich ecosystem and orthogonal language make thing convinient at best, atleast for me.

Personally, the five hassle I mention above still balanced with benefit that flutter provide. It's natural limitation which we need peacefully to accept.