Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flutterando/builders
Use Consumer, Select and BlocConsumer in any System Injector
https://github.com/flutterando/builders
Last synced: about 2 months ago
JSON representation
Use Consumer, Select and BlocConsumer in any System Injector
- Host: GitHub
- URL: https://github.com/flutterando/builders
- Owner: Flutterando
- License: apache-2.0
- Created: 2020-09-20T18:36:32.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-05-25T14:54:04.000Z (over 3 years ago)
- Last Synced: 2023-08-20T21:29:50.552Z (over 1 year ago)
- Language: Dart
- Homepage: https://pub.dev/packages/builders
- Size: 174 KB
- Stars: 4
- Watchers: 5
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# builders
Use Consumer, Select and BlocConsumer in any System Injector
## How Install
Open your project's pubspec.yaml and add flutter_modular as a dependency:
```dart
dependencies:
builders: any
```
You can also provide the git repository as source instead, to try out the newest features and fixes:```dart
dependencies:
builders:
git:
url: https://github.com/Flutterando/builders
```## Configure your System Injector
You can use any System Injector for example Modular or Get_it.
```dart
main(){
//using Modular
Builders.systemInjector(Modular.get);
//using Get_it
Builders.systemInjector(GetIt.I.get);runApp(YourAmazingApp());
}
```## Using in your Flutter App
Here are some Builders known to the community. Here we have Consumer and Selector (Originally from the Provider package) and BlocConsumer, (from the flutter_bloc package)
### Consumer
Consumer is used when you want to listen to a class that extends from ChangeNotifier:
```dart
class MyCounter extends ChangeNotifier {int value;
increment() {
value++;
notifyListeners();
}}
```
in your View:
```dart
Consumer(
builder: (context, myCounter){
return Text('${myCounter.value}');
}
);
```### Selector
Selector works like Consumers, however you can select and listen to only one property of your Object.
```dart
Selector(
selector: (myCounter) => myCounter.value,
builder: (context, value){
return Text('$value');
}
);
```### BlocConsumer
Listen to custom streams from the bloc package (Bloc and Cubit).
```dart
class MyCounterBloc extends Cubit {MyCounterBloc(): super(0);
increment() => emit(state + 1);
}
```
in your View:
```dart
BlocConsumer(
builder: (context, state){
return Text('$state');
}
);
```## Features and bugs
Please send feature requests and bugs at the [issue tracker](https://github.com/Flutterando/builders/issues).
This README was created based on templates made available by Stagehand under a BSD-style [license](https://github.com/dart-lang/stagehand/blob/master/LICENSE).