Skip to content

icnahom/scoped_listenable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Provides a Listenable to descendant widgets.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages