MockCommand<TParam, TResult> constructor

MockCommand<TParam, TResult>({
  1. required TResult? initialValue,
  2. bool noParamValue = false,
  3. bool noReturnValue = false,
  4. ValueListenable<bool>? restriction,
  5. ExecuteInsteadHandler<TParam>? ifRestrictedExecuteInstead,
  6. bool includeLastResultInCommandResults = false,
  7. ErrorFilter? errorFilter,
  8. bool notifyOnlyWhenValueChanges = false,
  9. String? debugName,
})

constructor that can take an optional ValueListenable to control if the command can be execute if the wrapped function has void as return type noResult has to be true

Implementation

MockCommand({
  required super.initialValue,
  super.noParamValue = false,
  super.noReturnValue = false,
  super.restriction,
  super.ifRestrictedExecuteInstead,
  super.includeLastResultInCommandResults = false,
  super.errorFilter,
  super.notifyOnlyWhenValueChanges = false,
  super.debugName,
}) {
  _commandResult
      .where((result) => result.hasData)
      .listen((result, _) => value = result.data);
}