err<T> function

AsyncSnapshot<T> err<T>(
  1. Object error, [
  2. StackTrace? stackTrace
])

Creates an AsyncSnapshot with an error (equivalent to Result.err)

Example:

final result = err<int>(Exception('Something went wrong'));
print(result.error); // Exception: Something went wrong

Implementation

AsyncSnapshot<T> err<T>(Object error, [StackTrace? stackTrace]) =>
    AsyncSnapshot.withError(
      ConnectionState.done,
      error,
      stackTrace ?? StackTrace.empty,
    );