same_type_streams_builder 0.1.0 copy "same_type_streams_builder: ^0.1.0" to clipboard
same_type_streams_builder: ^0.1.0 copied to clipboard

A builder widget for multiple streams of the same type.

This widget produces nested StreamBuilder widgets for your streams.

Usage #

final stream1 = Stream<int>.periodic(Duration(seconds: 1), (x) => x);
final stream2 = Stream<int>.periodic(Duration(seconds: 2), (x) => x);
final stream3 = Stream<int>.periodic(Duration(seconds: 3), (x) => x);


Widget build(BuildContext context) {
  return SameTypeStreamsBuilder<int>(
    streams: [stream1, stream2, stream3],
    builder: (context, snapshots) {
      return Text(
        'stream1: ${snapshots[0].data} - stream2: ${snapshots[1].data} - stream3: ${snapshots[2].data}',
      );
    },
  );
}

Additional information #

This widget is best if your streams are of the same type and their count is not known at compile time.

If your streams are of different types, you technically may use dynamic as their common type and then cast the snapshot data to your types. However, in this case it is best to use multiple_stream_builder package which has separate type for each stream (unrelated to me).

6
likes
100
pub points
0%
popularity

Publisher

verified publisherainkin.com

A builder widget for multiple streams of the same type.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on same_type_streams_builder