dependOnInheritedWidgetOfExactType<_InheritedProviderScope<>>() or dependOnInheritedElement() was called before .initState() completed.
Issue is Provider.of(context) is supposed to be used inside the widget tree,
and anything that is outside of the build() method, is not in the widget tree.
But if you still want to use it, then you need to set the listen parameter to
false.
Example:
@override
void initState() {
final _searchProvider = Provider.of<SearchProvider>(context, listen: false);
super.initState();
}