Skip to content

v4.3.0

Choose a tag to compare

@jacobaraujo7 jacobaraujo7 released this 11 Dec 15:52
· 343 commits to master since this release
bd0fdaf
  • 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