OnDispose class abstract

This class allows you to implement listeners notification when disposing object.

To notify listeners, create a dispose() method in your class.

class Test with OnDispose {
    // your class structure

    @override
    dispose() {
        // dispose your class and call `super.dispose()` to notify listeners
        super.dispose();
    }
}

final Test test = Test();
test.onDispose.add(() => print('Object disposed'));

test.dispose();

Constructors

OnDispose()

Properties

hashCode int
The hash code for this object.
no setterinherited
onDispose List<dynamic Function(dynamic)>
List of methods that will be called when the object is dropped.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Method that discards the object and notifies listeners
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyDispose() → void
Notify listeners with dispose of this object.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited