dispose method
Future<void>
dispose(
)
override
Implementation
@override
Future<void> dispose() {
return Future<void>.sync(() {
if (this._disposed != true) {
if (this._disposingFuture == null) {
this._disposingFuture = Future<void>.value();
final onDisposeResult = this.onDispose();
if (onDisposeResult is Future<void>) {
this._disposingFuture = this
._disposingFuture!
.then((_) => onDisposeResult)
.whenComplete(() {
this._disposingFuture = null;
this._disposed = true;
});
return this._disposingFuture;
} else {
this._disposed = true;
this._disposingFuture = null;
}
} else {
return this._disposingFuture;
}
}
}).catchError((Object err) {
final ex = FException.wrapIfNeeded(err);
print(
"Dispose method raised an error. This is unexpected behavior due dispose() should be exception safe. The error was bypassed.\n${ex.toString()}",
);
throw FExceptionDisposingFailure(ex, this);
});
}