toMap method

Map<String, dynamic> toMap()

Converts the InfospectNetworkRequest object into a Map representation.

Returns a Map with the following key-value pairs:

  • 'size': The size of the request data in bytes.
  • 'time': The timestamp when the request was made (in microseconds since epoch).
  • 'headers': The headers of the Network request.
  • 'body': The body of the Network request.
  • 'contentType': The content type (MIME type) of the request.
  • 'cookies': The cookies sent with the request (represented as a list of cookie names).
  • 'queryParameters': The query parameters of the request.
  • 'formDataFiles': List of file attachments (form data) if any, represented as a list of Maps.
  • 'formDataFields': List of form data fields if any, represented as a list of Maps.

Implementation

Map<String, dynamic> toMap() {
  return <String, dynamic>{
    'size': size,
    'time': time.microsecondsSinceEpoch,
    'headers': headers,
    'body': body,
    'contentType': contentType,
    'cookies': cookies.map((e) => e.name).toList(),
    'queryParameters': queryParameters,
    'formDataFiles':
        formDataFiles?.map((e) => e.toMap().getMap<dynamic>()).toList(),
    'formDataFields':
        formDataFields?.map((e) => e.toMap().getMap<dynamic>()).toList(),
  };
}