stream_subscription_builder 0.1.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 65

stream_subscription_builder #

A package to use and auto-close multiple stream subscriptions in flutter.

Usage #

Use StreamSubscriptionBuilder to subscribe and auto-dispose multiple subscriptions (StreamSubscription).

StreamSubscriptionBuilder(
    (context) => [
        bloc.stream().listen((event) => event.use((data) => print("Stream data: $data"))),
    ],
    child: Text("Child"),
);

Samples #

You can experiment with sample application hosted here: https://gitlab.com/marcin.jelenski/bloc-showcase

Also test directory contains all stream_subscription_builder use cases.

[0.1.0+1] - 1.12.2019

  • Initial release.

example/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:stream_subscription_builder/stream_subscription_builder.dart';

void main() {
  final controller = StreamController<String>();
  final stream = controller.stream;

  // Create builder instance
  StreamSubscriptionBuilder(
      (context) => [
            // Subscribe to stream. Subscription will be disposed when StreamSubscriptionBuilder is disposed.
            stream.listen((data) => print("Stream data: $data")),
          ],
      child: Container());
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  stream_subscription_builder: ^0.1.0+1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:stream_subscription_builder/stream_subscription_builder.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
31
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
effective_dart ^1.1.0
flutter_test
mockito ^4.1.1
test >=1.3.0 <2.0.0