dispose method

  1. @mustCallSuper
  2. @override
Future<Null> dispose()

Disposes this module and all its disposable dependencies.

If the module has only been instantiated and has not yet started loading or been loaded, then this will immediately dispose of the module.

If the module has already started loading, has loaded, or is in any other "loaded" state (suspending, suspended, resuming), then this will attempt to unload the module before disposing.

If the module has already started unloading, this will wait for that transition before disposing.

If the module has already started disposing or has disposed, then this will return the Future from didDispose. (An unloaded module will have already started or finished disposal).

In any of these cases where an unload is attemped prior to disposal, a failure during unload will be caught and logged, but will not stop disposal. A module who cancels unload via onShouldUnload or who throws during onUnload will still be disposed.

In short, calling dispose forces the disposal of this module regardless of its current state and regardless of its ability to unload successfully.

If the modules unload is canceled or if an error is thrown during a lifecycle handler like onUnload as a part of this disposal process, they will still be available via their corresponding lifecycle event streams (e.g. didUnload).

The Future returned from this method will resolve when disposal has completed and will only resolve with an error if one is thrown during onDispose.

Implementation

@mustCallSuper
@override
Future<Null> dispose() => super.dispose();