takeScreenshot method Null safety
- String screenshot
override
Takes a screenshot of the application. Returns the data that is sent back to the host.
Implementation
@override
Future<Map<String, dynamic>> takeScreenshot(String screenshot) async {
if (Platform.isAndroid && !_isSurfaceRendered) {
throw StateError('Call convertFlutterSurfaceToImage() before taking a screenshot');
}
integrationTestChannel.setMethodCallHandler(_onMethodChannelCall);
final List<int>? rawBytes = await integrationTestChannel.invokeMethod<List<int>>(
'captureScreenshot',
<String, dynamic>{'name': screenshot},
);
if (rawBytes == null) {
throw StateError('Expected a list of bytes, but instead captureScreenshot returned null');
}
return <String, dynamic>{
'screenshotName': screenshot,
'bytes': rawBytes,
};
}