utils library

Functions

fetchJsonAsOptional<T>({required FetchJsonParser fromJson, required FetchFunction fetch}) Future<Optional<T>>
fetchJsonAsOptional is a helper for fetching and parsing JSON data.
tryOptionalOrElse<T>(TryOptionalFutureFunction<T> future, {Optional<T> elseValue = const Optional.empty()}) Future<Optional<T>>
tryOptionalOrElse allows to get an elseValue when a optional future throws an error.
tryOrElse<T>(TryFutureFunction<T> future, {Optional<T> elseValue = const Optional.empty()}) Future<Optional<T>>
tryOrElse allows to get an elseValue when a future throws an error.

Typedefs

FetchFunction = Future<Map<String, dynamic>> Function()
FetchJsonParser<T> = T Function(Map<String, dynamic>)
TryFutureFunction<T> = Future<T> Function()
TryOptionalFutureFunction<T> = Future<Optional<T>> Function()