I got this error: Providers are not allowed to modify other providers during their initialization while updating notifier's state inside a ref.listen's listener. Multiple providers are involved, the dependencies:
MyNotifier -> data3 -> data
combine
-> data2 -> data
-> MyNotifier
The possibility is that the ref.listen's listener is called at the same time as the combine provider is still re-building.
Log:
provider start
provider end
provider start
set new state <-- here is changing the notifier's state while the provider is still building
provider end
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:riverpod/src/framework/element.dart': Failed assertion: line 477 pos 11: '_debugCurrentlyBuildingElement == null ||
_debugCurrentlyBuildingElement == this': Providers are not allowed to modify other providers during their initialization.
Describe the bug
Creating this issue as suggested in discord
I got this error:
Providers are not allowed to modify other providers during their initialization
while updating notifier's state inside aref.listen
's listener. Multiple providers are involved, the dependencies:MyNotifier
->data3
->data
combine
data2
->data
MyNotifier
The possibility is that the
ref.listen
's listener is called at the same time as thecombine
provider is still re-building.Log:
Full Log
Tried with versions:
To Reproduce
Expected behavior
There should be no error, or perhaps the listeners and provider building shouldn't be called at the same time