【Flutter】The following assertion was thrown building _SelectionKeepAlive(state: _SelectionKeepAliveState#f9ebd)

2022/10/19 23:28


The following assertion was thrown building _SelectionKeepAlive(state: _SelectionKeepAliveState#f9ebd):
dependOnInheritedWidgetOfExactType<_InheritedProviderScope<EditorStream?>>() or dependOnInheritedElement() was called before _EditorPageState.initState() completed.

When an inherited widget changes, for example if the value of Theme.of() changes, its dependent widgets are rebuilt. If the dependent widget’s reference to the inherited widget is in a constructor or an initState() method, then the rebuilt dependent widget will not reflect the changes in the inherited widget.

Typically references to inherited widgets should occur in widget build() methods. Alternatively, initialization based on inherited widgets can be placed in the didChangeDependencies method, which is called after initState and whenever the dependencies change thereafter.

The relevant error-causing widget was:



Just flutter clean, and restart your app. It it doesn’t work, resintall your app.

Leave a Reply

Back to top