ChangeNotifier

ChangeNotifier is a Flutter class that holds state and notifies its listeners with notifyListeners() when it changes. Combined with Provider or ListenableBuilder, it rebuilds only the widgets concerned. It is a simple way to share state between several screens.

Example

class Panier extends ChangeNotifier {
  final _items = <String>[];
  void ajouter(String s) { _items.add(s); notifyListeners(); }
}

Related concepts

The whole glossary