scoped_listenable 1.4.0 copy "scoped_listenable: ^1.4.0" to clipboard
scoped_listenable: ^1.4.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),
    // Or
    counterModel.scoped(),
    // Or
    ScopedListenable.builder((context, child) {
      return ScopedListenable(
        listenable: counterModel,
        child: child,
      );
    }),
  ],
  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.

0
likes
0
points
24
downloads

Publisher

unverified uploader

Weekly Downloads

Provides a Listenable to descendant widgets.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on scoped_listenable