For a very detailed overview of Flutter architecture on all platforms, see this doc.
A Flutter component for Fuchsia is an ELF binary that is built and run using Fuchsia's Bazel SDK. The component is launched by Fuchsia's ELF runner (there is no longer a separate Flutter runner or Dart runner).
Building and running an example Flutter component is done by:
Compiling the Flutter application to get a folder of compiled assets (snapshot, fonts, images).
This is currently done with the Flutter CLI using
flutter build bundle. This only supports JIT compilation. To support AOT compilation, we should switch to using the Dart SDK's tools instead (see this doc for reference).
Running the embedder executable with the ELF runner. This is handled by the Bazel SDK.
We pass the path to the compiled assets as an argument here.
The compiled Flutter component's package has three main folders:
bin/embedder: The executable.
data/flutter_assets/: The compiled assets of the Flutter app that should be run by the executable.
lib/: Shared libraries that are used by
lib/libflutter_engine.so is the Flutter Engine code that
bin/embedder uses to run the Flutter app.
When building and running a Flutter example, the full package contents are printed for debugging.
The easiest way to understand how threading works in Flutter is to attach a debugger in VS Code and break on a function that you're interested in. VS Code will tell you what thread the code is running on.
Some notable threads:
Platform thread (
initial-thread): The thread that
main() runs on.
Raster thread (
io.flutter.raster): Handles rendering logic for Flutter.