recipeOf<T extends Equatable> function

T recipeOf<T extends Equatable>({
  1. required BuildContext context,
  2. required T fallbackData,
  3. required bool listen,
})

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

Implementation

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