prepareScreenCapture static method
Prepare for screen capture on Android 14+ (SDK 34+).
On Android 14+, this sets up monitoring to automatically start the foreground service when flutter_webrtc's permission dialog is completed.
Call this BEFORE calling flutter_webrtc's getDisplayMedia().
On Android 10-13, this is a no-op (use startScreenCaptureService instead). On other platforms, this returns true immediately.
Returns true if preparation was successful.
Implementation
static Future<bool> prepareScreenCapture() async {
if (kIsWeb || !Platform.isAndroid) {
return true;
}
try {
debugPrint('QuickRTC: Preparing screen capture');
final result = await _channel.invokeMethod<bool>('prepareScreenCapture');
return result ?? false;
} on PlatformException catch (e) {
debugPrint('Failed to prepare screen capture: ${e.message}');
return false;
} on MissingPluginException {
debugPrint('QuickRTC platform plugin not available');
return true;
}
}