You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like guidance on how to avoid this problem that occurs with some users. It's not a general error.
It seems that flutter disables/dispose the context during my app's initialization flow.
I'm using FutureBuilder in initState.
The screen only loads after the future method finishes calling several routines.
I initialize my Provider in initiState like this:
in my getDataIni method I initialize remote config settings, notifications, etc and call a method from my provider. In some devices it is giving this error when calling the provider method: await _userDataController.loadData(context);
Error:
Null check operator used on a null value
#0 State.context (package:flutter/src/widgets/framework.dart:954)#1 _HomePageState.getDataIni.....)#2 _FutureBuilderState._subscribe. (package:flutter/src/widgets/async.dart:628)
I know it's a flutter error and not the provider. But how do I avoid this and guarantee state for the entire application?
My widget is a stateFullWidget.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I would like guidance on how to avoid this problem that occurs with some users. It's not a general error.
It seems that flutter disables/dispose the context during my app's initialization flow.
I'm using FutureBuilder in initState.
The screen only loads after the future method finishes calling several routines.
I initialize my Provider in initiState like this:
@override void initState() { super.initState(); WidgetsBinding.instance.addObserver(this); _userDataController = Provider.of<UserDataController>(context, listen: false); futureResult = getDataIni(); }
in my getDataIni method I initialize remote config settings, notifications, etc and call a method from my provider. In some devices it is giving this error when calling the provider method:
await _userDataController.loadData(context);
Error:
Null check operator used on a null value
#0 State.context (package:flutter/src/widgets/framework.dart:954)#1 _HomePageState.getDataIni.....)#2 _FutureBuilderState._subscribe. (package:flutter/src/widgets/async.dart:628)
I know it's a flutter error and not the provider. But how do I avoid this and guarantee state for the entire application?
My widget is a stateFullWidget.
Beta Was this translation helpful? Give feedback.
All reactions