orbital 0.1.0
orbital: ^0.1.0 copied to clipboard
Full Orbital package that reexports core, injector and router.
orbital #
Bundle package that reexports orbital_core, orbital_injector and
orbital_router, plus a convenience bootstrap for the Orbital DevTools
runtime bridge.
When to use this package #
Use orbital when you want the full Orbital stack from a single import:
import 'package:orbital/orbital.dart';
Choose the individual packages when you want tighter dependency boundaries:
orbital_corefor contracts onlyorbital_injectorfor dependency scopes without Flutter routingorbital_routerfor Flutter routing on top of Orbital scopes, using an explicitscopeFactoryorbital_devtoolsfor the Flutter DevTools UI extension that consumes the Orbital debug snapshots
Quick start #
final logger = OrbitalLogger();
enableOrbitalDevtools(logger: logger, appId: 'my-app');
MaterialApp.router(
routerConfig: OrbitalApp.router(
logger: logger,
scopeFactory: const DefaultOrbitalScopeFactory(),
initialUri: Uri.parse('/'),
modules: [
OrbitalModule(
path: '/',
routes: [
OrbitalPageRoute(
path: '/',
builder: (context, routeContext) => const HomePage(),
),
],
),
],
),
);
Key concepts #
OrbitalBindingdefines dependency creation strategiesOrbitalDependencyRefdefines readiness dependenciesOrbitalContainerresolves bindings inside scope treesOrbitalModuleandOrbitalPageRoutedefine the navigation treeOrbitalMiddlewareguards navigation
Async dependencies and dependsOn #
Use dependsOn to guarantee readiness order, not to inject values into the
factory signature.
OrbitalBinding.singletonAsync<ApiClient>((resolver) async {
return ApiClient.connect();
}),
OrbitalBinding.singleton<HomeController>(
(resolver) => HomeController(
resolver.get<ApiClient>(),
),
dependsOn: [OrbitalDependencyRef.of<ApiClient>()],
),
This allows a sync controller to depend on async services safely after scope initialization.
More detail #
See doc.md for package relationships, lifecycle flow and guidance on when to use the bundle versus the individual packages.