disposeMixInstance method
Future<void>
disposeMixInstance(
)
Implementation
@protected
@mustCallSuper
Future<void> disposeMixInstance() async {
assert(_status != MixInstanceStatus.dispose,
'Once you have called dispose() on a MixInstance $typeName, it can no longer be used.');
// 'Once you have called dispose() on a MixInstance $typeName, it can no longer be used.');
if (_status == MixInstanceStatus.dispose) return;
// if the instance is not loaded, we can dispose it immediately
if (_status == MixInstanceStatus.none) {
_status = MixInstanceStatus.dispose;
return;
}
// if the instance is loading, we need to wait for it to finish loading
await _waitInit();
// if the instance is loaded, we can dispose it
_status = MixInstanceStatus.dispose;
await _manager.disposeMixInstance(
typeName,
this,
);
}