takeScreenshot method Null safety

Future<List<int>> takeScreenshot(
  1. String screenshotName
)

Takes a screenshot.

On Android, you need to call convertFlutterSurfaceToImage(), and pump a frame before taking a screenshot.

Implementation

Future<List<int>> takeScreenshot(String screenshotName) async {
  reportData ??= <String, dynamic>{};
  reportData!['screenshots'] ??= <dynamic>[];
  final Map<String, dynamic> data = await callbackManager.takeScreenshot(screenshotName);
  assert(data.containsKey('bytes'));

  (reportData!['screenshots']! as List<dynamic>).add(data);
  return data['bytes']! as List<int>;
}