prepareJsonExceptionFunction method

bool Function(JsonUnsupportedObjectError exception)? prepareJsonExceptionFunction({
  1. ExceptionExplanationModel? exceptionExplanationModel,
  2. BuildContext? context,
})

Prepares a JsonUnsupportedObjectError handling function based on the provided context and exception model.

  • exceptionExplanationModel contains information about the exception for displaying in the alert dialog.
  • context is the current build context.
  • generalFunction is a function to handle exceptions when a specific function is not provided, and context is null. It is only invoked in this case.

Returns a function to handle the JsonUnsupportedObjectError.

Implementation

bool Function(JsonUnsupportedObjectError exception)?
    prepareJsonExceptionFunction({
  ExceptionExplanationModel? exceptionExplanationModel,
  BuildContext? context,
}) {
  if (context == null) {
    return (JsonUnsupportedObjectError exception) {
      debugPrint(exception.toString());
      return true;
    };
  }

  return (JsonUnsupportedObjectError exception) => showAlertDialog(
        context,
        "UnsupportedObject Error",
        "An UnsupportedObject error occurred.",
        "Close",
      );
}