Trigger FutureProvider load - best practices? #1291
-
I use package_info_plus for getting the app version number to show in the Settings page. Loading the PackageInfo is an async call and I want to expose it to my settingsProvider using a FutureProvider. If the object was mandatory for running the app I would async load it in main before calling runApp() but in this case I would prefer not to block the app as the settings page is not something that the user will probably use every time and certainly not immediately after starting, so having an AsyncValue settings object is fine. I would like, however, to load the value sometime in the background to have it ready when the settings page will be opened, instead of showing a circular loading widget. What is the best practice to having riverpod call the FutureProvider in the background, ahead of time, when the app starts? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Simply read your provider anywhere and it will get initialized |
Beta Was this translation helpful? Give feedback.
Simply read your provider anywhere and it will get initialized