Last active
December 10, 2019 07:52
-
-
Save JEuler/8661948def66bdab30fdb5f846dd8eba to your computer and use it in GitHub Desktop.
FlutterAppMultiProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FlutterApp extends StatelessWidget { | |
final WebService _webService; | |
final StorageService _storageService; | |
FlutterApp(this._webService, this._storageService); | |
@override | |
Widget build(BuildContext context) { | |
var localizationDelegate = LocalizedApp.of(context).delegate; | |
return MultiProvider( | |
providers: [ | |
Provider<WebService>( | |
builder: (_) => WebService.create(AppConfig.of(context).apiBaseUrl), | |
dispose: (context, WebService service) => service.client.dispose(), | |
), | |
Provider<StorageService>( | |
builder: (_) => StorageServiceImpl(), | |
dispose: (context, StorageService service) => service.stop(), | |
), | |
Provider<SomeKindOfStore>( | |
builder: (_) => SomeKindOfStore(_webService, _storageService), | |
dispose: (context, SomeKindOfStore store) => store.dispose(), | |
), | |
child: MaterialApp( | |
title: 'FlutterApp', | |
home: MainPage(store: Provider.of<SomeKindOfStore>(context)))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment