toMap method

Map<String, dynamic> toMap({
  1. EnumMethod? enumMethod,
})

Converts instance to a map.

Implementation

Map<String, dynamic> toMap({EnumMethod? enumMethod}) {
  return {
    "action": switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => action?.toNativeValue(),
      EnumMethod.value => action?.toValue(),
      EnumMethod.name => action?.name(),
    },
    "data": data,
    "event": event?.toMap(enumMethod: enumMethod),
    "headers": headers?.toMap(enumMethod: enumMethod),
    "isAsync": isAsync,
    "method": method,
    "password": password,
    "readyState": switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => readyState?.toNativeValue(),
      EnumMethod.value => readyState?.toValue(),
      EnumMethod.name => readyState?.name(),
    },
    "response": response,
    "responseHeaders": responseHeaders,
    "responseText": responseText,
    "responseType": responseType,
    "responseURL": responseURL?.toString(),
    "responseXML": responseXML,
    "status": status,
    "statusText": statusText,
    "url": url?.toString(),
    "user": user,
    "withCredentials": withCredentials,
  };
}