handleFunction method

void handleFunction({
  1. required OnHandleFunctionStateFullWidget<T> onFunction,
  2. OnHandleErrorStateFullWidget<T>? onError,
})

Implementation

void handleFunction({
  required OnHandleFunctionStateFullWidget<T> onFunction,
  OnHandleErrorStateFullWidget<T>? onError,
}) {
  Future(() async {
    try {
      await onFunction(context, widget);
    } catch (error, stack) {
      OnHandleErrorStateFullWidget<T>? eFunction = onError;
      if (eFunction != null) {
        await eFunction(error, stack, widget);
      } else {
        rethrow;
      }
    }
  });
}