scoped_listenable 1.0.0 copy "scoped_listenable: ^1.0.0" to clipboard
scoped_listenable: ^1.0.0 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 ScopedContainer.

ScopedContainer(
  container: [
    ScopedListenable.from(counterModel),
    ScopedListenable.from(settingsModel),
  ],
  child: MyApp(),
);

To obtain Listenable directly, use extension methods.

void initState() {
  context.get<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 of the package.

0
likes
120
pub points
0%
popularity

Publisher

unverified uploader

Provides a Listenable to descendant widgets.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on scoped_listenable