flutter_modular library

flutter_modular v7 — clean rewrite (work in progress).

Navigator 2.0 (route matching + page stack + guards + transitions), the module system (createModule / ModularContext), page-scoped state (provide / Scoped + context.watch/read/select, Consumer/Selector; addChangeNotifier/addStream as the rule, addStreamable/addListenable for BLoC/Cubit-style objects, add for non-reactive resources), and nested routes (children + RouterOutlet).

Classes

Consumer<T extends Object>
Rebuilds ONLY its builder when T's trigger notifies — scopes the rebuild to a sub-widget instead of the whole page (the granular alternative to watch). T is the page-scoped value (a ChangeNotifier, a bloc registered via addStreamable, etc.); rebuilds are driven by its trigger.
CustomTransition
A PageTransition you build inline by supplying just the animation.
Disposable
A page-scoped resource that needs cleanup. Implement it on any class and register it via Scoped.add to have it built in the page-local injector and dispose()d when the page leaves the stack — even though it is not a Listenable/ChangeNotifier.
ModularApp
The root widget of a Modular app. It bootstraps module once (collecting its routes + DI), owns the resulting injector, builds the RouterConfig, and — sitting ABOVE the MaterialApp — hosts optional APP-SCOPED state via provide. That position is exactly what lets an app-global view model (theme, locale, session) rebuild the MaterialApp itself, which page-scoped state (living below the Navigator) cannot reach.
ModularBootstrap
Result of bootstrapping a root module: the route tree, the resolution injector, and the manager that drives per-module bind lifecycle.
ModularContext
The single surface a module declares itself through: DI registration (add*), routes (route, with guards/transition/nested children), and the unified module include verb.
ModularRoute
A single declared route: a RELATIVE path pattern, a builder, optional page-scoped state (provide), nested children, guards and a transition.
Module
A module SPEC: declares DI + Routes via register. Build it functionally with createModule (a final value, deduped by identity) or by extending.
ModuleManager
Owns the resolution root injector and drives per-FEATURE-module bind lifecycle: a feature module's binds are bound (its tagged injector created and composed in) when its first route enters the stack, and disposed (via disposeInjectorByTag) when its last route leaves — mirroring how the "active path list" worked in flutter_modular 6.x.
PageTransition
The contract a route transition implements: given a key and the route's child, it produces the Page that wraps it in the navigator stack.
RouteCollection
The declared route tree + the hierarchical matcher.
RouteLevel
One matched level of a route chain: the route + its captured path params.
RouterOutlet
Renders the child route(s) of the current level in a REAL nested Navigator — with its own push/pop sub-stack. Calling context.pushNamed from inside an outlet targets THIS outlet, so the parent shell persists, and its returned Future completes with the value passed to pop(result). Scope nests through it: a child's context.watch reaches the parent's VMs.
RouterOutletState
RouteState
Immutable snapshot of the route the app is currently resolving.
Scoped
Registrar for PAGE-SCOPED state, used in route(provide: (scoped) {...}).
Selector<T extends Object, R>
Rebuilds its builder only when the SELECTED value R changes — surgical reactivity over a page-scoped value T (a view model, a bloc, etc.).
StreamValue<T>
A ChangeNotifier holding the latest value emitted by a Stream.

Enums

TransitionType
Built-in transition presets. Each value is itself a PageTransition, so transition: TransitionType.fade keeps working while the field accepts any custom PageTransition.

Extensions

ModularNavigationX on BuildContext
Navigation from any widget.
ModularStateX on BuildContext
Page-scoped state access from any descendant of the page.

Functions

bootstrapModule(Module root) ModularBootstrap
Walks a root Module, collecting its routes (tagged with their owning feature modules) and binds. Root-owned binds (path-less modules) are committed eagerly; feature binds (a module with a path) are bound lazily on entry and disposed on exit.
createModule({String? path, required void register(ModularContext c)}) Module
Creates a functional module. Store it in a final and reference the SAME value everywhere — composition dedups by IDENTITY.
inject<T>() → T
Resolves T from the active module graph — Angular-style service access that keeps the injector object PRIVATE. Works anywhere a constructor can't inject for you (route guards, callbacks, widgets) after a Modular app has bootstrapped. It reads the LIVE graph, so a feature module's binds are reachable only while that module is active.
modularRouterConfig(RouteCollection routes, {AutoInjector? injector, ModuleManager? manager, String initialRoute = '/', GlobalKey<NavigatorState>? navigatorKey, List<NavigatorObserver> observers = const [], PageTransition defaultTransition = TransitionType.material}) RouterConfig<RouteState>
Wires the Navigator 2.0 pieces into a RouterConfig for MaterialApp.router(routerConfig: ...).

Typedefs

ModularGuard = String? Function(RouteState state)
A route guard: returns a redirect path to send the user elsewhere, or null to allow navigation.
ModularWidgetBuilder = Widget Function(BuildContext context, RouteState state)
Builds the widget for a route, receiving the current RouteState.