exceptionFor static method

UserException? exceptionFor(
  1. BuildContext context,
  2. Object actionOrTypeOrList, {
  3. bool notify = true,
})

Returns the UserException of the actionTypeOrList that failed.

The actionTypeOrList can be a Type, or an Iterable of types. Any other type of object will return null and throw a StoreException after the async gap.

It's recommended that you use the BuildContext extension instead:

if (context.isFailed(SaveUserAction)) Text(context.exceptionFor(SaveUserAction)!.reason ?? '');

Widgets that use this method WILL rebuild whenever the state changes (unless you pass the notify parameter as false).

Implementation

static UserException? exceptionFor(
  BuildContext context,
  Object actionOrTypeOrList, {
  bool notify = true,
}) =>
    (notify ? _getStoreWithDependency_Untyped : _getStoreNoDependency_Untyped)(context)
        .exceptionFor(actionOrTypeOrList);