requestMicrophone static method

Future<bool> requestMicrophone()

Request microphone permission (audio calls). Returns true if granted or already granted.

Implementation

static Future<bool> requestMicrophone() async {
  // On web, the browser prompts for permissions when WebRTC starts.
  // permission_handler does not support web — skip native request.
  if (kIsWeb) return true;

  final before = await Permission.microphone.status;
  developer.log(
    'CallPermissions.requestMicrophone: status before request = $before',
  );
  final status = await Permission.microphone.request();
  developer.log(
    'CallPermissions.requestMicrophone: status after request = $status',
  );
  if (!status.isGranted) {
    developer.log('CallPermissions: microphone permission denied ($status)');
  }
  return status.isGranted;
}