takeScreenshot method

Future<List<int>> takeScreenshot(
  1. String screenshotName, [
  2. Map<String, Object?>? args
])

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, [Map<String, Object?>? args]) async {
  reportData ??= <String, dynamic>{};
  reportData!['screenshots'] ??= <dynamic>[];
  final Map<String, dynamic> data = await callbackManager.takeScreenshot(screenshotName, args);
  assert(data.containsKey('bytes'));

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