multiple_stream_builder 1.1.1 copy "multiple_stream_builder: ^1.1.1" to clipboard
multiple_stream_builder: ^1.1.1 copied to clipboard

outdated

Flutter widgets to replace multiple nested StreamBuilder widgets

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:multiple_stream_builder/multiple_stream_builder.dart';
import 'package:tuple/tuple.dart';

void main() {
  runApp(ExampleApp());
}

class ExampleApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Multiple Stream Builder Example',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Multiple Stream Builder Example'),
        ),
        body: ExampleScreen(),
      ),
    );
  }
}

class ExampleScreen extends StatefulWidget {
  @override
  _ExampleScreenState createState() => _ExampleScreenState();
}

class _ExampleScreenState extends State<ExampleScreen> {
  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);

  @override
  Widget build(BuildContext context) {
    return StreamBuilder3<int, int, int>(
      streams: Tuple3(stream1, stream2, stream3),
      initialData: Tuple3(0, 0, 0),
      builder: (context, snapshots) {
        return Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('stream1: ${snapshots.item1.data}'),
              Text('stream2: ${snapshots.item2.data}'),
              Text('stream3: ${snapshots.item3.data}'),
            ],
          ),
        );
      },
    );
  }
}
38
likes
40
points
3k
downloads

Publisher

verified publisherlevizitting.com

Weekly Downloads

Flutter widgets to replace multiple nested StreamBuilder widgets

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, tuple

More

Packages that depend on multiple_stream_builder