I've read that Dart uses its own DartVM. Thus Flutter can use JIT (for things like hot-reload) while developing your app and AOT to build the latter into a "native" app (.apk/.ipa).
According to the docs for both platforms (Android/iOS):
ahead-of-time (AOT) compiled into a native, ARM library
But how does Flutter use its own DartVM, for example, on Android, if the app already runs via Dalvik/ART? And does the VM is built into our .apk so it can be delivered to a real Android device?
If DartVM isn't used for the end-builds then what about the GC stuff? Flutter tends to create a lot of short-lived objects which is fine for DartVM's Generational GC but isn't so good for the ART's one.
The Flutter engine uses the Dart VM in two distinct modes:
flutter run
command watches the host filesystem for changes to Dart source, and when it detects such changes, quickly compiles the Dart source to kernel (intermediate) format. This is then synced to the engine running on the device via hot-reload, and executed in JIT mode (Android) or interpreted mode (iOS).gen_snapshot
, which emits AOT ARM machine code, which is then linked into the final app. You can find a detailed explanation of AOT mode operation on our wiki.Note that there's a thin set of platform bindings for Android written in Java that interface with the engine via JNI, but the core of Flutter's engine is written in C++ and built with the NDK, as such those bits aren't relying on Dalvik/ART.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With