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
&StateProvider
changed to
StatefulWidget
update the state inside
setState
and change the state in the following function inside the class