Search packages, repositories and app categories

GitHub repositoryglitchedmob/flutter_multiple_stream_builder

flutter_multiple_stream_builder

glitchedmob/flutter_multiple_stream_builder open-source repository details.

flutter_multiple_stream_builder project cover
Stars
11
Forks
2
Last push (UTC)
Jun 22, 2022
Project status
Active

Original README

English project snapshot. Visit GitHub for the latest content.

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

dependencies:
  multiple_stream_builder: ^3.0.0

Usage example

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

// Instead of writing out nested StreamBuilders
Widget build(BuildContext context) {
  return StreamBuilder<int>(
    stream: stream1,
    initialData: 0,
    builder: (context, snapshot1) {
      return StreamBuilder<int>(
        stream: stream2,
        initialData: 0,
        builder: (context, snapshot2) {
          return StreamBuilder<int>(
            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<int, int, int>(
    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}',
      );
    },
  );
}
Levi Zitting GitHub avatar
GitHub author

Levi Zitting ↗

Senior Software Engineer - Currently using and loving, Go, K8s and Terraform

Jack HenrySpringfield MOOfficial website ↗
LanguagesDart

Packages published by this repository

Dependencies used

Dependency list 3 items

  • flutter{"sdk":"flutter"}
  • flutter_testDevelopment{"sdk":"flutter"}
  • flutter_lintsDevelopment^2.0.1

How do I choose a repository?

Start with your use case, compare repository activity, and check the original project before adopting it.

  1. Search by repository name, owner or description, then narrow the results by topic.
  2. Compare stars, forks and recent pushes. Stars show community interest, not a guarantee of quality.
  3. Read the README, license and issues on GitHub before using a project.

Sources and maintenance

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗