scoped_listenable 2.0.2 copy "scoped_listenable: ^2.0.2" to clipboard
scoped_listenable: ^2.0.2 copied to clipboard

Provides a Listenable to descendant widgets.

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(),
);

Observe changes in the Listenable provided by an ancestor widget.

ScopedBuilder<CounterModel>(
  builder: (context, listenable, child) {
    return Text('${listenable.counter}');
  },
);

Advanced #

To add multiple ScopedListenables, use ScopedListenable.merge.

ScopedListenable.merge(
  listenables: [
    counterModel.scoped(),
    settingsModel.scoped(),
  ],
  child: MyApp(),
);

To obtain Listenable directly, use extension methods.

void initState() {
  context.read<CounterModel>().reset();
Widget build(BuildContext context) {
  final counterModel = context.watch<CounterModel>();

Additional information #

This is an updated version of scoped_model. Credits to the original authors and maintainers.

0
likes
140
points
13
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Provides a Listenable to descendant widgets.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on scoped_listenable