Search code examples
flutterobserver-patternflutter-provider

Does Flutter's provider package support ordered listeners?


does Flutter's provider package support the notion of ordered listeners?

In my concrete example I would like to make sure that a particular listener of my ChangeNotifier is executed before a Consumer widget of that change notifier.

If there's no specific feature for this purpose, can somebody tell me how Provider naturally orders the listeners of a ChangeNotifier? Does it solely depend on the registration time of the listener/consumer? (FIFO principle)

Thanks in advance


Solution

  • Consumer isn't relying on listeners to work, but on a different mechanism (InheritedWidgets)

    Consumer.builder isn't called during notifyListeners. It is called by the Flutter framework when building the Widget tree, which happens at a completely different time.