My addSteps function require access to the context. I have a repository object that is stored here.
Future<int> _addSteps() async {
repository = RepositoryProvider.of<lo.Repository>(context);
...
}
The future _addStepsFuture
is created in didChangeDependencies
.
didChangeDependencies() {
addStepsFuture = _addSteps();
}
Although the context is recived later in the Build call.
FutureBuilder<int>(
future: _addStepsFuture,
)
The BuildContext
is not available until Build
is called.
Is there a way to solve this problem? Thank you.