flutter_modular 7.1.0 copy "flutter_modular: ^7.1.0" to clipboard
flutter_modular: ^7.1.0 copied to clipboard

Smart project structure with dependency injection and route management for Flutter.

Changelog #

7.1.0 #

  • Feature modules can now consume shared/core dependencies directly. A module-level bind inside a feature (a module with a path) — addSingleton, add, addLazySingleton — now resolves dependencies registered in a root-owned shared module (a path-less module(...), the "core"). Previously only page-scoped provide binds could reach the core; a feature's module-level binds ran in a leaf injector that couldn't see root-owned binds, forcing shared deps to be threaded in by hand. This removes that asymmetry: a core consumer can be a provide, the core itself, OR a feature module-level bind — all alike. A feature's own bind still shadows a same-typed core bind (local wins; core is the fallback).
  • Requires auto_injector >= 2.2.0, which adds the opt-in upward resolution (addInjector(child, resolveUpward: true)) this builds on, fixes a dispose-listener accumulation in its layer graph, and adds an UpwardResolutionCycle guard against mutual upward links.

7.0.3 #

  • Customizable route transitions. route(transition:) and the new app-wide ModularApp(defaultTransition:) now accept any PageTransition, an open contract that builds the route's Page. Three ways to supply one:
    • the TransitionType presets (material, fade, none) — each value now is a PageTransition, so existing transition: TransitionType.fade keeps working;
    • CustomTransition — the inline convenience: pass a transitionsBuilder (same signature as PageRouteBuilder) and optionally tune duration/reverseDuration/opaque/barrierColor/ barrierDismissible/fullscreenDialog; Modular still owns the Page;
    • implement PageTransition yourself for full control of the Page (e.g. a CupertinoPage with swipe-back, a fullscreenDialog, shared-axis from the animations package).
  • App-wide default. ModularApp.defaultTransition (default TransitionType.material) applies to every route that doesn't declare its own. Precedence: route-local → app default → material. route(transition:) now defaults to null (inherit the app default) instead of forcing material.

7.0.2 #

  • context.select<T, R>(selector) — the method-based twin of the Selector widget. Reads a value derived from a page-scoped T and rebuilds the calling widget only when the selected value changes (==). Mirrors context.select from provider to ease migration; call it from build.

7.0.1 #

  • Page-scoped BLoC/Cubit support. New Scoped.addStreamable<T>(ctor, (t) => t.stream, (t) => t.close()) exposes the object itself via context.watch<T>() (read its synchronous state, call its methods) while rebuilds are driven by its stream — flutter_modular keeps no dependency on the bloc package (stream/close are caller callbacks). Companion addListenable<T>(ctor, (t) => t.listenable, (t) => t.dispose()) for objects whose reactivity is a Listenable property. See the docs for a suggested addBloc extension covering both BLoC and Cubit.
  • add<T>(ctor) — non-reactive page-scoped object, readable via context.read/watch and disposed on unmount when it implements Disposable. Breaking: replaces addDisposable, which is removed (the Disposable interface is retained).
  • addChangeNotifier reexpressed over addListenable; watch/read/Consumer/Selector now accept any Object (not just Listenable), so a non-Listenable reactive object can be exposed.

7.0.0-dev.1 #

Ground-up rewrite of flutter_modular. Breaking: the v6 API (Module with List<Bind> get binds / List<ModularRoute> get routes, Bind, ChildRoute, ModuleRoute, the global Modular facade, and the modular_core engine) is replaced. v7 is a single, self-contained Flutter package (depends directly on auto_injector + web; modular_core is gone).

  • Modules are DI + Routes only, declared functionally with createModule(register:) and a flat ModularContext (addSingleton/add*, route(path, child:, provide:, children:, guards:, transition:), module(value, {at}) to include shared deps or mount submodules). Deduped by identity; path-less modules are root-owned (shared), path-bearing modules are features with their own DI lifecycle (bound on first route entry, disposed on last exit).
  • Navigator 2.0, fully declarative: hierarchical route matching with /:params, RouterOutlet for persistent shells with their own nested stack, guards/redirects, transitions. context.pushNamed/navigate/replace/pop (+ popUntil/popAndPushNamed/pushNamedAndRemoveUntil). URL mirrors the stack base; pushes stay out of the URL by design. Relative routes resolve against the current location.
  • Page-scoped state via provide: addChangeNotifier / addStream / addDisposable build state 1:1 with the view in a page-local injector and dispose it when the route leaves. Read with context.watch/read/select and the Consumer/Selector widgets. App-scoped state goes on ModularApp(provide:) (above MaterialApp).
  • context.routeState() — reactive access to the current RouteState (uri + resolved params + arguments) for route-aware chrome.
  • inject<T>() for runtime resolution where a constructor can't inject (e.g. route guards).

See example/ for a complete app exercising every feature.

1.32k
likes
160
points
75.9k
downloads

Documentation

API reference

Publisher

verified publisherflutterando.com.br

Weekly Downloads

Smart project structure with dependency injection and route management for Flutter.

Repository (GitHub)
View/report issues
Contributing

License

MIT (license)

Dependencies

auto_injector, flutter, flutter_web_plugins, meta, web

More

Packages that depend on flutter_modular