Task<S, F>.fail constructor
Task<S, F>.fail (
- F value, [
- Object? exception,
- StackTrace? stack
Creates a task that fails with the given value and an optional exception and stack trace, for stubbing in tests:
when(() => weatherApi.fetchForecast(any()))
.thenReturn(Task.fail(WeatherError.offline));
Implementation
Task.fail(F value, [Object? exception, StackTrace? stack])
: this._(t.Task.fail(value, exception, stack));