disposable_object 2.0.0 icon indicating copy to clipboard operation
disposable_object: ^2.0.0 copied to clipboard

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

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
likes
130
pub points
35%
popularity

Publisher

verified publisher iconmagicleon94.dev

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

Homepage

Documentation

API reference

License

Icon for licenses.MIT (LICENSE)

Dependencies

meta

More

Packages that depend on disposable_object