genesis_generator
Generates typed startup registrations and diagnostic graphs for Genesis. Use Dart 3.9 or later to run the generator.
Installation
Once both packages are available on pub.dev, add these dependencies to your application.
dependencies:
genesis: ^2.0.0
dev_dependencies:
build_runner: ^2.7.1
genesis_generator: ^2.0.0
Usage
Define startup functions in lib/genesis.dart with @GenesisTask and
@GenesisProvider. Include part 'genesis.g.dart'; in that library.
From the application's package directory, generate the startup code.
dart run build_runner build
Import the application's genesis.dart and call await runGenesis() from the
entry point. The quick start shows
both files. The runnable example
uses the workspace packages from a checkout.
The builder writes lib/genesis.g.dart for startup and
.dart_tool/genesis_graph.json for genesis:doctor.
Generated registrations
- Typed provider registrars for
@GenesisProviderfunctions. - Task descriptors for configure, init, and execution.
- A
GenesisPackageManifestused by runtime diagnostics. - Bootstrap functions for directly imported Genesis dependencies.
@GenesisProvider and @GenesisTask(phase: ...) methods may use required
positional provider object parameters. The generator injects those values with
genesisReadProvider<T>() and records the inferred parameter metadata.
@GenesisTask(requires: ...) records order-only dependencies, and
@GenesisTask(provides: ...) records readiness tokens that do not require a
function return value.
@GenesisProvider(eager: true) is emitted into both provider descriptors and
graph metadata. Task GenesisCondition values are emitted into task
descriptors and the graph so runtime planning and doctor output stay aligned.
The builder checks that lib/genesis.dart imports each direct Genesis
dependency. It checks for duplicate type sources, provider cycles, and invalid
phase dependencies after applying task conditions for each platform and build
mode. Mutually exclusive task outputs can share a type. Run Doctor on the
resulting graph to check for missing dependencies.
Documentation
- Code generation guide covers Flutter and multi-package integration.
- Flutter container guide shows generation across an app and its reusable containers.
- Doctor guide covers graph checks and diagrams.
- Generator API reference is available after publication.