Should you use “extends” or “with” keyword for ChangeNotifier? - Flutter
问题 I have seen several examples of a model extending ChangeNotifier using both 'extends' and 'with' keywords. I am not sure what the difference is. class myModel extends ChangeNotifier {...} class myModel with ChangeNotifier {...} What is the difference between those two? Which one should I use? 回答1: You can use either extends (to inherit) or with (as a mixin). Both ways give you access to the notifyListeners() method in ChangeNotifier . Inheritance Extending ChangeNotifier means that