这对于使用StreamingSharedPreferences
的{{1}}来说很简单
Provider
因为我在应用程序中还有另一个Future<void> main() async {
final preferences = await StreamingSharedPreferences.instance;
final settings = MyAppSettings(preferences);
runApp(
Provider<MyAppSettings>.value(value: settings, child: MyApp()),
);
}
,例如:
Provider
我不确定如何在其中创建runApp(
MultiProvider(providers: [
Provider(builder: (_) => database.userTableDao),
Provider(builder: (_) => database.postsTableDao),
Provider(builder: (_) => database.postsTableDao),
Provider(
builder: (_) => ApiService.create(),
dispose: (_, ApiService) => service.client.dispose(),
)
], child: OKToast(child: MyHomePage())),
);
提供程序,例如:
StreamingSharedPreferences
答案 0 :(得分:0)
final settings = ApplicationSettings( await StreamingSharedPreferences.instance );
MultiProvider(providers: [
...
Provider( builder: (_) => settings ),
...
], child: OKToast(child: MyHomePage())),