Targets · Dart · Native modules
Native modules
The hand-written, per-platform code behind NATIVE functions.
Contents
How a Program becomes Dart, in parts. Start with the introduction, then follow each part into the rendered output and the runtime it links against.
- Introduction — what the Dart target is, and how to read the rest of this section.
- Capabilities — which high-level features are possible, built in or through a library.
- Example — a full program using every keyword, and the Dart it renders to.
- Naming considerations — how Program's dotted names are carried into Dart.
- Entry point — starting a program and mounting it as a Flutter app.
- Drivers — the native drivers that provide the interface, animation and network.
- Runtime — the Reactive and Context machinery the rendered code links against.
- Native modules — the hand-written Dart behind
NATIVEfunctions. - Keywords — how each of Program's keywords renders to Dart.
- Project setup — the files and commands to build and run the rendered program.
- Reserved words — the words Dart keeps for itself, and how a colliding name is escaped.
Hand-written Dart behind NATIVE
A function's hand-written dart NATIVE
body is dropped in where the function is called, wrapped so its inputs arrive as plain Dart values.
static ReactiveValue<double> Add(dynamic a, dynamic b) {
return Reactive.Calculate<double>(() {
final a = Reactive.Value<double>(__reactive_a);
final b = Reactive.Value<double>(__reactive_b);
return a + b; // the dart NATIVE body
});
}
As on JavaScript, the drivers are native code too — the Flutter interface driver, animation and network live in their modules' native Dart — and the runtime (Reactive, Context) is itself a native module the rest builds on.