Targets · Dart · Entry point

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.

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.