Last updated:
0 purchases
scoped listenable
Getting started #
Add scoped_listenable as a dependency in your pubspec.yaml file.
Usage #
Provide a Listenable to descendant widgets.
ScopedListenable(
listenable: counterModel,
child: MyApp(),
);
copied to clipboard
Observe changes in the Listenable provided by an ancestor widget.
ScopedBuilder<CounterModel>(
builder: (context, listenable, child) {
return Text('${listenable.counter}');
},
);
copied to clipboard
Advanced #
To add multiple ScopedListenables, use ScopedContainer.
ScopedContainer(
container: [
ScopedListenable.from(counterModel),
ScopedListenable.from(settingsModel),
],
child: MyApp(),
);
copied to clipboard
To obtain Listenable directly, use extension methods.
void initState() {
context.get<CounterModel>().reset();
copied to clipboard
Widget build(BuildContext context) {
final counterModel = context.watch<CounterModel>();
copied to clipboard
Additional information #
This is an updated version of scoped_model.
Credits to the original authors and maintainers of the package.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.