Entry point
Starting a program and mounting it as a Flutter app.
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.
One call, mounted with runApp
A program starts with a single call that takes the root component and the
drivers it uses. On Dart the result is a Flutter
widget, so it is handed straight to runApp — the running program is the
app's root.
void main() {
runApp(Program.Application(
() { Counter(); }, // the root component
[ Ui.Flutter.Driver() ], // render as Flutter widgets
));
}
The root component is the run body: its calls emit the interface, its state lives across cycles, and its nesting becomes nested closures (see the example). Flutter owns the lifecycle — when the widget is unmounted the program's drivers are torn down.
The model is exactly the JavaScript entry
point; only the mount differs — runApp and a widget instead of a DOM element
and a cancel.