flutterflutter-change-notifier

Callback on calling notifyListeners when using ChangeNotifier


I need to listen to a callback or something after every notifyListeners called, while i am using Change notifier

it's is something like WidgetsBinding.instance.addPostFrameCallback((_) but this in case of using setState or rendering the frame for the first time


Solution

  • So it appears to that you can register WidgetsBinding.instance.addPostFrameCallback((_) under the consumer widget for ChangeNotifierProvider , so in that case after every notifyListeners the consumer will be called and a callback for it will be registered after it the frame is already rendered.