Is it possible to update StateProvider from the Class outside the Widget?
Or I need to use another way?
My code
class SettingScreen extends ConsumerWidget with WidgetsBindingObserver {
This is the place I would like to update the state
Widget build(BuildContext context, WidgetRef ref) {
Update and read state working fine
}
}
var locationPermissionProvider = StateProvider<bool>((_) => true,);
I found a simple solution and it's working
removed
WidgetRef&StateProviderchanged to
StatefulWidgetupdate the state inside
setStateand change the state in the following function inside the class