toJson method

Future<Map<String, Object?>> toJson({
  1. bool includeImages = true,
  2. bool includeUniformBytes = false,
})

Serializes the capture. With includeImages, every thumbnail is read back as PNG first (asynchronous), and with includeUniformBytes each draw keeps its packed uniform bytes. The result round-trips through RenderGraphCaptureResult.fromJson, so a capture can be attached to a bug report and opened elsewhere.

Implementation

Future<Map<String, Object?>> toJson({
  bool includeImages = true,
  bool includeUniformBytes = false,
}) async {
  if (includeImages) {
    for (final resource in resources) {
      await resource.encodeThumbnailPng();
    }
  }
  return {
    'version': 1,
    'pixelWidth': pixelWidth,
    'pixelHeight': pixelHeight,
    'passes': [
      for (final pass in passes)
        pass.toJson(includeUniformBytes: includeUniformBytes),
    ],
    'resources': [
      for (final resource in resources)
        resource.toJson(includePng: includeImages),
    ],
  };
}