rx_provider

Last updated:

0 purchases

rx_provider Image
rx_provider Images
Add to Cart

Description:

rx provider

Features #
Drop-in replacement of Provider with lots of features.
Getting started #
Usage #
Define store before using it. Store can be anything
class MyClass extends ConsumerNotifier {
int value = 0;

increment() {
value++;
notifyListeners();
}
}

String myStoreOne = 'my store';
List<int> myStoreTwo = [1, 2, 3, 4, 5];
MyClass myStoreThree = MyClass();
copied to clipboard
Then use Provider to map stores.
// single store
Provider(
id: 'sad',
store: myStoreTwo,
child: Column(
children: [
Consumer(
id: 'sad',
notifierBuilder: (BuildContext context, List<int> taste, rebuild) {
return GestureDetector(
onTap: () {
myStoreTwo.add(0);
rebuild();
},
child: Text(taste.join(', ')),
);
},
),
],
)
)

// multiple stores
Provider(
stores: {
'tasteOne': myStoreOne,
'tasteTwo': myStoreTwo,
},
child: Column(
children: [
Consumer(
store: 'tasteOne',
builder: (BuildContext context, String taste) {
return Text(taste);
},
),
Consumer(
stores: ['tasteTwo'],
notifierBuilder: (BuildContext context, storeMap, Function rebuild) {
List<int> taste = storeMap['tasteTwo'];

return GestureDetector(
onTap: () {
myStoreTwo.add(0);
notifyConsumers('sad.default');
rebuild();
},
child: Text(taste.join(', ')),
);
},
),
],
),
)
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.