screenMirror method

Future<SendPort> screenMirror({
  1. required ReceivePort answer,
  2. ScreenRecordOptions recordingOptions = const ScreenRecordOptions(),
  3. FFPlayOptions playOptions = const FFPlayOptions(),
})

Start screen recording answer - ReceivePort to listen for the response recordingOptions - ScreenRecordOptions playOptions - FFPlayOptions Returns SendPort to control the screen recording

Example:

final answer = ReceivePort();
final sendPort = await client.shell().screenMirror(answer: answer);
sendPort.send('start');

Future.delayed(Duration(seconds: 10), () {
 sendPort.send('stop');
});

await for (final message in answer) {
 print(message);
}

Implementation

Future<SendPort> screenMirror({
  required ReceivePort answer,
  ScreenRecordOptions recordingOptions = const ScreenRecordOptions(),
  FFPlayOptions playOptions = const FFPlayOptions(),
}) async {
  final response = ReceivePort();
  final screenArgs = [..._connection.arguments, 'shell', 'screenrecord', ...recordingOptions.toArgs(), '-'];
  final ffplayArgs = [...playOptions.toArgs()];

  await Isolate.spawn(_screenMirrorTask, response.sendPort);
  final sendPort = await response.first;
  sendPort.send(['setup', answer.sendPort, screenArgs, ffplayArgs]);
  return sendPort;
}