disposables 0.1.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new68

CircleCI pub package

Simple library to manage objects needing to release its own resources.

Disposable

final sink = StreamController();
final disposable = Disposable(() => sink.close());
disposable.dispose();

For more complex disposable object you can implement the Disposable interface yourself.

class SomeObject implements Disposable {
  @override
  bool isDisposed = false;
  @override
  void dispose() {
    isDisposed = true;
  }
}

DisposableCollection

final disposables = [SomeObject(), SomeObject(), disposable];
final collection = DisposableCollection(disposables);
collection.dispose();

If you want to compose disposables into without mutating after creation consider using compose.

final disposable = Disposable.compose(disposables);
disposable.dispose();

0.1.0

  • Initial version.

0.1.1

  • Added using function.

example/disposables_example.dart

import 'dart:async';

import 'package:disposables/disposables.dart';

main() {
  final sink = StreamController();
  final disposable = Disposable(() => sink.close());
  disposable.dispose();
}

Use this package as a library

1. Depend on it

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


dependencies:
  disposables: ^0.1.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:disposables/disposables.dart';
  
Version Uploaded Documentation Archive
0.1.2 Nov 14, 2018 Go to the documentation of disposables 0.1.2 Download disposables 0.1.2 archive
0.1.1 Nov 13, 2018 Go to the documentation of disposables 0.1.1 Download disposables 0.1.1 archive
0.1.0 Nov 13, 2018 Go to the documentation of disposables 0.1.0 Download disposables 0.1.0 archive
0.0.1 Nov 4, 2018 Go to the documentation of disposables 0.0.1 Download disposables 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
36
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]
68
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:disposables/disposables.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
quiver ^2.0.1 2.0.1
Transitive dependencies
matcher 0.12.4
meta 1.1.6
path 1.6.2
stack_trace 1.9.3
Dev dependencies
test ^1.0.0