maybeRecipeOf<T extends Equatable> function

T? maybeRecipeOf<T extends Equatable>({
  1. required BuildContext context,
  2. required bool listen,
})

Returns the recipe of type T from the context, or null if no recipe was found.

Implementation

T? maybeRecipeOf<T extends Equatable>({
  required BuildContext context,
  required bool listen,
}) {
  try {
    return Provider.of<T>(context, listen: listen);
  } on ProviderNotFoundException {
    return null;
  }
}