Task<S, F>.fail constructor

Task<S, F>.fail(
  1. F value, [
  2. Object? exception,
  3. 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));