Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/glitchedmob/flutter_multiple_stream_builder
https://github.com/glitchedmob/flutter_multiple_stream_builder
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/glitchedmob/flutter_multiple_stream_builder
- Owner: glitchedmob
- License: mit
- Created: 2020-12-17T18:30:52.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-22T06:02:46.000Z (over 2 years ago)
- Last Synced: 2024-08-03T14:07:48.419Z (7 months ago)
- Language: Dart
- Homepage: https://pub.dev/packages/multiple_stream_builder
- Size: 110 KB
- Stars: 11
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# multiple_stream_builder
Flutter widgets to replace multiple nested StreamBuilder widgets
## Installing
To add use this package in your Flutter project add this to your `pubspec.yml`
```yml
dependencies:
multiple_stream_builder: ^3.0.0
```## Usage example
```dart
var stream1 = Stream.periodic(Duration(seconds: 1), (x) => x);
var stream2 = Stream.periodic(Duration(seconds: 2), (x) => x);
var stream3 = Stream.periodic(Duration(seconds: 3), (x) => x);// Instead of writing out nested StreamBuilders
Widget build(BuildContext context) {
return StreamBuilder(
stream: stream1,
initialData: 0,
builder: (context, snapshot1) {
return StreamBuilder(
stream: stream2,
initialData: 0,
builder: (context, snapshot2) {
return StreamBuilder(
stream: stream3,
initialData: 0,
builder: (context, snapshot3) {
return Text(
'stream1: ${snapshot1.data} - stream2: ${snapshot2.data} - stream3: ${snapshot3.data}',
);
},
);
},
);
},
);
}// Pass multiple streams into a single StreamBuilder
Widget build(BuildContext context) {
return StreamBuilder3(
streams: StreamTuple3(stream1, stream2, stream3),
initialData: InitialDataTuple3(0, 0, 0),
builder: (context, snapshots) {
return Text(
'stream1: ${snapshots.snapshot1.data} - stream2: ${snapshots.snapshot2.data} - stream3: ${snapshots.snapshot3.data}',
);
},
);
}
```