Skip to main content


Modular also has an InheritedWidget instance that can use the dependsOn API of [BuildContext]. This way, the developer can recover binds and, if it is a supported reactivity, will watch the modifications changing the state of the widget in question.

The watch() method was added to [BuildContext] through extensions, making access easy.

class Body extends StatelessWidget {  Widget build(BuildContext context){    final notifier =<ValueNotifier>();    return Text('${notifier.value}')  }}

Supported reactivities are:

Used in ChangeNotifier/ValueNotifier classes and in RxNotifier.

Used in StreamController.


In addition to the method, the read-only method has been added. It's the same as using Modular.get(), but this addition helps projects that are being migrated Provider.

With selectors#

Sometimes binds are not a supported reactivity, but one of their properties can be. As in the case of BLoC, where the Stream is available through a property;

We can add a selection through an anonymous function indicating which property is a supported reactivity to be watched:

class Body extends StatelessWidget {  Widget build(BuildContext context){    final bloc =<CounterBloc>((bloc) =>;    return Text('${bloc.state}')  }}

Note that the use of the selector does not change on bind return.

We can also use selectors for Triple objects, which have their own selectors for each of their segments: See the Triple documentation for more details by clicking here:

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

It's also possible to configure a selector directly in bind:

@overridefinal List<Bind> binds = [  //selector returns stream or listenable to use  Bind.singleton((i) => MyBloc(), selector: (bloc) =>,];

Existem Bind pré-configurados para BLoC e Triple. Veja os packages modular_bloc_bind e modular_triple_bind