Genesis

Genesis is a modular startup framework for Dart and Flutter. The name means “origin” or “beginning”. It reflects the framework's job of bringing an app's modules together and getting their services ready to use.

A Genesis container is a reusable Dart package that starts an SDK or feature in the Flutter app's process.

  • Reuse SDK startup across apps. The container owns initialization. Each host app supplies its own options and adapters.
  • Start modules with runGenesis(). The generated runner wires dependencies by Dart type and runs tasks through configure, init, and execution. Tasks in the same phase can run concurrently when ready.
  • Check startup in CI. Doctor can check for missing dependencies across packages and export a Mermaid graph of startup tasks and their dependencies.

The Flutter container example shows how a host app connects an asset reader to a reusable catalog initializer.

The runtime supports Android, iOS, macOS, Windows, Linux, Web, and OHOS with an OHOS-enabled SDK. It requires Dart 3.8 or later and runs on the Dart SDK without Flutter. The Doctor command runs on the Dart VM.

Installation

Once genesis is available on pub.dev, add it to your project.

dart pub add genesis

For a Flutter project, use flutter pub add genesis.

Usage

For annotation-based startup, add genesis_generator and build_runner as development dependencies. Follow the quick start to define providers and tasks, generate lib/genesis.g.dart, and call runGenesis().

Manual registration

Register providers and tasks with genesisRegisterPackageTasks, then call genesisRunExecution with the same package ID. Each task declares its typed dependencies in requires. Tasks can read those values with genesisReadProvider<T>() and publish a result using output.

The manual registration example loads a message catalog during init and uses it during execution. From the repository root, run the example with dart run genesis/example/main.dart after resolving dependencies with dart pub get.

Startup phases

Phase Entry point Typical use
Configure genesisRunConfigure Configure clients and wire adapters.
Init genesisRunInit Initialize shared services and storage.
Execution genesisRunExecution Start application workflows.

Each entry point also runs its prerequisite phases. Tasks in the same phase can run concurrently when their dependencies are ready. Successful work is reused on subsequent calls. Calling a phase again after a failure retries failed work.

  • Use requires for typed dependencies and provides for readiness tokens that do not carry a value. Use output when a task returns a value.
  • Providers are lazy by default. Set eager: true to construct a provider at startup. Eager providers cannot depend on task outputs.
  • Use GenesisCondition to select platforms or build modes. Make sure each selected task's dependencies are available in the same environment.
  • Execution tasks without outputs can use GenesisTaskSchedule.deferred or GenesisTaskSchedule.idle to schedule background work. Idle scheduling yields to the Dart event loop.

For multi-package startup, register each package and pass its direct Genesis package IDs in dependencies. Start the application by passing its package ID. Use genesisDescribePlan(packageId: ...) to inspect the registered graph and GenesisRunReport.toJson() to examine execution results.

Doctor

Doctor reads .dart_tool/genesis_graph.json from a code generation build. Run these commands from your application package after generating the graph.

dart run genesis:doctor --check
dart run genesis:doctor --graph

See the Doctor guide for JSON output and workspace checks.

Documentation

Libraries

genesis
Typed, staged startup orchestration for Dart and Flutter applications.
testing