onError property

Widget Function(Object? error, StackTrace? stackTrace)? onError
final

A callback that returns a widget to be displayed in the case of an error. The callback also provides access to the error and stacktrace.

Note: Leaving this as null will create a fallback pattern of:

  1. If onError is null, fallback to onData if it's not null.
  2. Otherwise, fallback to the fallbackWidget if it's not null.
  3. Or as last resort, fallback to a SizedBox.shrink() (essentialy blank space). Therefore, it's encouraged to handle this state althoguh it is optional.

Implementation

final Widget Function(Object? error, StackTrace? stackTrace)? onError;