disposable_object 1.0.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 68

disposable #

A simple interface to manage disposable objects, their disposal and check their disposed status.

Getting Started #

Just make your disposable object extend Disposable and implement the disposeInstance override!

Example #

import 'dart:async';

import 'package:disposable/disposable.dart';

class MyDisposableObject extends Disposable {
  final streamController = StreamController.broadcast();
  @override
  void disposeInstance() {
    streamController.close();
  }
}

void main() {
  final object = MyDisposableObject();
  print('Stream closed: ${object.streamController.isClosed}');
  print('Object disposed: ${object.disposed}');

  object.dispose();

  print('Stream closed: ${object.streamController.isClosed}');
  print('Object disposed: ${object.disposed}');
}

1.0.0+1 #

Public API comments added

1.0.0 #

First release

example/main.dart

import 'dart:async';

import 'package:disposable_object/disposable_object.dart';

class MyDisposableObject extends DisposableObject {
  final streamController = StreamController.broadcast();
  @override
  void disposeInstance() {
    streamController.close();
  }
}

void main() {
  final object = MyDisposableObject();
  print('Stream closed: ${object.streamController.isClosed}');
  print('Object disposed: ${object.disposed}');

  object.dispose();

  print('Stream closed: ${object.streamController.isClosed}');
  print('Object disposed: ${object.disposed}');
}

Use this package as a library

1. Depend on it

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


dependencies:
  disposable_object: ^1.0.0+1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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:disposable_object/disposable_object.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
37
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 Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14

Health suggestions

Format lib/disposable_object.dart.

Run dartfmt to format lib/disposable_object.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
meta ^1.1.8 1.2.2 1.3.0-nullsafety
Dev dependencies
pedantic ^1.8.0