getOrFallback method

Future<T> getOrFallback(
  1. T fallback
)

Gets the stored value or returns a fallback if the value is null.

This is a convenience method that combines get() with a null check.

Example:

final coins = PrfInt('coins');
final value = await coins.getOrFallback(0); // Returns 0 if not set

Implementation

Future<T> getOrFallback(T fallback) async {
  return (await get()) ?? fallback;
}