toMap method

Map<String, dynamic> toMap()

Converts the ThreadWebRequest instance into a Map<String, dynamic> representation.

This method serializes the request's properties into a map for easier data transfer or conversion to formats like JSON.

The resulting map contains the following key-value pairs:

  • 'id': The unique identifier of the request.
  • 'mode': The mode of the operation (fixed to 'encode').
  • 'generateOnlyImageBounds': Always null, as it is not used in this operation.
  • 'outputFormat': The output format of the image (e.g., 'png', 'jpeg').
  • 'jpegChroma': The chroma subsampling mode for JPEG format (e.g., 'yuv444').
  • 'pngFilter': The PNG filter type used for compression.
  • 'jpegQuality': An int specifying the JPEG quality (0–100).
  • 'pngLevel': An int specifying the PNG compression level (0–9).
  • 'singleFrame': A bool indicating whether to process a single frame only.
  • 'image': A Map<String, dynamic> representation of the image, created using imageToMap.

Implementation

Map<String, dynamic> toMap() {
  return {
    'id': id,
    'mode': mode,
    'generateOnlyImageBounds': null,
    'outputFormat': outputFormat.name,
    'jpegChroma': jpegChroma.name,
    'pngFilter': pngFilter.name,
    'jpegQuality': jpegQuality,
    'pngLevel': pngLevel,
    'singleFrame': singleFrame,
    'image': imageToMap(),
  };
}