Is there a way to pre load state on app start (before material app runs) #842
Replies: 4 comments 2 replies
-
You can read your providers at any time, which will cause them to load. |
Beta Was this translation helpful? Give feedback.
-
It could just be something like:
|
Beta Was this translation helpful? Give feedback.
-
fwiw, I am loading user configuration from disk before calling and then overwrite the value in the Future<void> main() async {
final appData = await loadData();
runApp(ProviderScope(
overrides: [
appDataProvider.overrideWithValue(appData),
],
child: App(),
);
} |
Beta Was this translation helpful? Give feedback.
-
I'm using splash screen with value notifier to initialize services/notifiers and then override providers. It's probably not the cleanest approach but gets the job done. A good example of such approach is in this repo memo |
Beta Was this translation helpful? Give feedback.
-
Describe what scenario you think is uncovered by the existing examples/articles
I am dynamically building routes (vRouter) using a change notifier waiting on an API call. Is there a way to preload state before material app is built so I can make sure my routes are ready?
Describe why existing examples/articles do not cover this case
I have not seen anything that covers pre loading state before building the app in the documentation.
Beta Was this translation helpful? Give feedback.
All reactions