Basically I want to load firebase remote config parameters when app starts and store it in app state while creating store.
So that whenever I need it I just fetch it from store and get remoteConfig value.
class App extends StatelessWidget {
// Get firebase remote config and store it in appState
---> final store = createStore();
App();
@override
Widget build(BuildContext context) {
return new PersistorGate(
persistor: persistor,
loading: new LoadingScreen(),
builder: (context) => new StoreProvider<AppState>(
store: store,
child: new MaterialApp(
title: 'TestApp',
theme: defaultTargetPlatform == TargetPlatform.iOS
? kIOSTheme
: kDefaultTheme,
routes: getRoutes(context, store),
initialRoute: '/login',
)),
);
}
}
Create Store file -
Store<AppState> createStore() {
Store<AppState> store = new Store(
appReducer,
// store remote config in initial app state
initialState: new AppState(),
middleware: createMiddleware(),
);
persistor.load(store);
return store;
}