Flutter: complete turnaround

Published by Leff on

Being an Android dev for about 4-5 years, I’ve got used to writing billions of adapters, factories and other .util stuff I don’t really need, since it’s just mandatory and tedious af.

10-something of April, 2018. Google announces Fuchsia OS. 10++-something of April, 2018. Google announces Flutter beta-2. That’s where it has got much more interesting.

I always wanted to go for cross-platforming stuff, but I didn’t want to become proficient in JS like those crazy guys in the office. That’s where I’ve tried Flutter.

Flutter & Dart from the perspective on Android Middle, here we go.

This is how we create a card for a ListView in Flutter.

“At first I thought that it was spaghetti JS-like code that must not work.
Now I think it’s amazing and one of the most things structure-wise I’ve ever experienced.”
That is how I can sum up my experience with Flutter. Let’s deconstruct it and see why it’s amazing.

Let’s compare how applications work on Android+Java vs Flutter+Dart.
Android+Java: UNIX Core > Android > JVM > Application.
That means, we’re stuck with Android, JVM only works on it and can’t go outside without any modules.
Flutter+Dart: UNIX Core > Android > JVM > LLVM(Flutter) > Application
LLVM is a render engine, which executes Dart code. That means, we must use its interface, which can work with Android’s.

At first glance, it seems terrible, since we increase the level of abstraction. In reality, it’s quite amazing because Google really took care of making Android development as tedious as it’s theoretically possible.

Writing the application for LLVM, we can stop caring about Android>JVM level of functioning and it’s abysmal problems (adapters, lifecycle, crashes without logs or stacktraces, etc), let alone saying that LLVM has a much better GC (not without its problems on the front-end side of the Moon as for 16th of April, 2018, though).

Let’s start off with my test app for the university’s schedule that I’ve written in about 2 days on weekend. This is the part of the code, responsible for launching a Flutter application. I don’t think it’s hard to read, but I have to make a remark about

“primaryColor: defaultTargetPlatform == TargetPlatform.iOS
? Colors.white
: null),”

Yes, Flutter is cross-platform, but there are some platform-specific bits, that happen with implementing that stupid iPhone X notch at the top, around which we must work.

I strongly advice you to reference Flutter Gallery.
Its source code is on GitHub.
You can easily scavenge the code from there and make your own application.

If you’re interested, look for tutorials and guides, since I don’t really think that high of myself as a teacher.