Skip to content

Releases: Flutterando/modular

v7.1.0

24 Jun 01:58
0f41054

Choose a tag to compare

Feature modules can now consume shared/core dependencies

A feature module's module-level bind (addSingleton, add, addLazySingleton) now resolves dependencies registered in a root-owned shared/core module (a path-less module(...)). Previously only page-scoped provide binds could reach the core; a feature's module-level binds ran in a leaf injector blind to root-owned binds, forcing shared deps to be threaded in by hand.

A core consumer can now 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

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.

Docs

New dependency-injection.md sections: cross-module resolution and the async bootstrap idiom (await once in a Future<Module> builder so main stays thin and features take no parameters).

Full changelog: https://pub.dev/packages/flutter_modular/versions/7.1.0/changelog

v7.0.1

23 Jun 03:28
d1eef13

Choose a tag to compare

๐Ÿ“ฆ Published on pub.dev: https://pub.dev/packages/flutter_modular/versions/7.0.1

Page-scoped BLoC/Cubit support

  • 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). See the docs for a suggested addBloc extension covering both BLoC and Cubit.
  • addListenable<T>(ctor, (t) => t.listenable, (t) => t.dispose()) โ€” for objects whose reactivity is a Listenable property.

Simpler non-reactive registration

  • add<T>(ctor) โ€” non-reactive page-scoped object, readable via context.read/watch, disposed on unmount when it implements Disposable. Breaking: replaces addDisposable (removed; the Disposable interface is retained).

Internals

  • addChangeNotifier reexpressed over addListenable; watch/read/Consumer/Selector now accept any Object (not just Listenable), so a non-Listenable reactive object can be exposed. Fully backward compatible.

Full Changelog: https://github.com/Flutterando/modular/blob/master/CHANGELOG.md

v5.0.3

03 Jun 17:46
3567303

Choose a tag to compare

v5.0.2

13 May 00:10
c513de7

Choose a tag to compare

  • Fix: Parse params in RouteOutlet

v5.0.1

12 May 17:53
e0583d5

Choose a tag to compare

  • Support Cubit

v5.0.0

12 May 00:19
1ce79b6

Choose a tag to compare

  • Support Flutter 3.0.0
  • [BREAK CHANGE]: Removed MaterialApp.modular() and Cupertino().modular().
    Use instead:
      return MaterialApp.router(
        routeInformationParser: Modular.routeInformationParser,
        routerDelegate: Modular.routerDelegate,
      );
    

This modification aims to keep Modular support independent of WidgetApp updates, and can be used in other bootstraps such as FluentApp [fluent_ui].

  • [BREAK CHANGE]: New auto-dispose configuration.
    Previously Modular had automatic closing or destruction calls for objects of type ChangeNotifier/ValueNotifier, Stream and Triple`s Stores.
    Starting with version 5.0, Modular will provide the Bind.onDispose property for calls to destroy, close or dispose methods FOR EACH BIND. This will make the dispose settings more straightforward and less universal. Therefore, Modular will manage the destruction of Binds that implement Disposable only. This is the new configuration:
@override
final List<Bind> binds = [
  Bind.singleton((i) => MyBloc(), onDispose: (bloc) => bloc.close()),
];

The Bind.onDispose CANNOT be used in Bind type factory.
You can choose to use Bind.onDispose or implement the Disposable class.

  • Added Bind.selector. Generates a reactivity (Listenable/Stream) to be listened to when context.watch() is called.
@override
final List<Bind> binds = [
  //notifier return stream or listenable to use context.watch()
  Bind.singleton((i) => MyBloc(), onDispose: (bloc) => bloc.close(), selector: (bloc) => bloc.stream),
];
  • [BREAK CHANGE]: As already described above, the reactivities worked externally to Modular, providing a
    longer life to the project. For this reason, BLoC or Triple users should use special Bind's in order to use the context.watch() and auto dispose functionality. They are: BlocBind() and TripleBind(), which are available through external packages.
    modular_bloc_bind -> BlocBind

    modular_triple_bind -> TripleBind

Example:

@override
final List<Bind> binds = [
  BlocBind.singleton((i) => MyBloc()),
];
  • [BREAK CHANGE] Bind.export works only after imported.

  • @deprecated ModularState.
    A few months of research showed us that ModularState caused unnecessary coupling with the view and made it difficult for those who used it to understand. For this reason, we decided to deprecate it to ensure code congruence for all professionals who use Modular.

  • Removed triple dependency.

  • Simplify docs.

  • Added Modular.setArguments.

Modular.setArguments('cody1024d');

// get
Modular.args.data; // -> cody1024d
//or
Bind((i) => MyClass(i.args.data));

Issues

v4.5.0

22 Feb 03:25
e7cdfdb

Choose a tag to compare

  • @deprecated: .modular() extension.
    Use instead:
      return MaterialApp.router(
        routeInformationParser: Modular.routeInformationParser,
        routerDelegate: Modular.routerDelegate,
      );
    
  • Added Modular.setInitialRoute.
  • Added Modular.setObservers.
  • Added Modular.setNavigatorKey.

v4.3.0

11 Dec 15:52
bd0fdaf

Choose a tag to compare

  • Added BuildContext extension [context.read()] and [context.watch()];
  • The [context.watch()] listen changes of [Listanable], [Stream] and [Store] by Triple;
class Body extends StatelessWidget {
  Widget build(BuildContext context){
    final notifier = context.watch<ValueNotifier>();
    return Text('${notifier.value}')
  }
}
  • Use select in .watch() to select the reactive property:
class Body extends StatelessWidget {
  Widget build(BuildContext context){
    final bloc = context.watch<CounterBloc>((bloc) => bloc.stream);
    return Text('${bloc.state}')
  }
}

Also, use Store Selectors in conjunction with .watch:

class OnlyErrorWidget extends StatelessWidget {
  Widget build(BuildContext context){
    // changes with store.setError();
    final store = context.watch<MyTripleStore>((store) => store.selectError);
    return Text('${store.error}')
  }
}

See more details here

4.1.2

04 Oct 18:44

Choose a tag to compare

  • Added "maintainState" in routes. #572
  • Fixed pushReplacementNamed.

Version 4.0.1

22 Sep 06:47
86db0c5

Choose a tag to compare

  • Fixed pushNamed.
  • Fixed bug that allowed access to parameters and arguments in other modules.
  • Fixed transitions bug.