handle<T> method

dynamic handle<T>({
  1. required Future<T> fetch(),
  2. required dynamic onValue(
    1. T t
    ),
  3. dynamic onError(
    1. Object error
    )?,
})
inherited

Implementation

handle<T>({
  required Future<T> Function() fetch,
  required Function(T t) onValue,
  Function(Object error)? onError,
}) async {
  try {
    onValue(await fetch());
  } catch (error) {
    onResponseError(error);
    onError?.call(error);
  }
}