Skip to content

Instantly share code, notes, and snippets.

@DevKhalyd
Created July 23, 2020 21:10
Show Gist options
  • Save DevKhalyd/db3695efb986e7a5644e4d565c29f9c9 to your computer and use it in GitHub Desktop.
Save DevKhalyd/db3695efb986e7a5644e4d565c29f9c9 to your computer and use it in GitHub Desktop.
ProxyProvider Example
import 'package:vento_app/notifiers/data_stores_notifiers.dart';
import 'package:vento_app/notifiers/search_item.dart';
//ProxyProvider
class SearchStoreProxy {
//Notifier
DataStoreNotifier _dataStore;
//Notifier
SearchItemNotifier _searhItems;
//Constructor
SearchStoreProxy(this._dataStore, this._searhItems);
DataStoreNotifier get dataStore => _dataStore;
SearchItemNotifier get searhItems => _searhItems;
}
//Use in main
MultiProvider(
providers: [
ChangeNotifierProvider<SearchItemNotifier>(
create: (_) => SearchItemNotifier(),
),
ChangeNotifierProvider<DataStoreNotifier>(
create: (_) => DataStoreNotifier(),
),
//2 means classes to use
ProxyProvider2<SearchItemNotifier, DataStoreNotifier,
SearchStoreProxy>(
update: (context, item, store, proxy) => SearchStoreProxy(
store,
item,
),
)
],
child: MaterialApp(
title: 'Vento App',
initialRoute: initialRoute(),
debugShowCheckedModeBanner: false,
routes: {
LoginScreen.route: (c) => LoginScreen(),
ListStores.route: (c) => ListStores()
},
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment