dispose method

  1. @override
void dispose()
override

If you don't need a command any longer it is a good practise to dispose it to make sure all registered notification handlers are remove to prevent memory leaks

Implementation

@override
void dispose() {
  assert(!_isDisposing,
      'You are trying to dispose a Command that was already disposed. This is not allowed.');
  _isDisposing = true;

  _commandResult.dispose();
  _canExecute.dispose();
  _isExecuting.dispose();
  _errors.dispose();
  if (!(_futureCompleter?.isCompleted ?? true)) {
    _futureCompleter!.complete(null);
    _futureCompleter = null;
  }

  super.dispose();
}