paymentErrorsToMap static method

Map<String, dynamic> paymentErrorsToMap(
  1. dynamic data
)

Converts payment error data to a map format. data - The payment error data to be converted. Returns a map containing the converted payment errors.

Implementation

static Map<String, dynamic> paymentErrorsToMap(data) {
  if (data == null) return {};

  // Check if data is actually a list
  if (data is List<dynamic>) {
    Map<String, dynamic> convertedMap = {};
    for (var item in data) {
      if (item is Map<String, dynamic>) convertedMap.addAll(item);
    }
    return convertedMap;
  } else {
    // Handle the case where data is not as expected
    throw const FormatException('Data is not in the expected format');
  }
}