setEnabled method

Future<void> setEnabled(
  1. bool enabled
)

Implementation

Future<void> setEnabled(bool enabled) async {
  if (!isSupported) return;
  try {
    await _channel.invokeMethod<void>('setProximitySensorEnabled', enabled);
  } on MissingPluginException {
    // 应用未注册 Kit 插件时保持原有播放能力,不阻断语音。
  } on PlatformException catch (error) {
    // 系统传感器不可用时同样保持播放主流程可用。
    debugPrint('设置接近感应监测失败: $error');
  } catch (_) {
    // The Flutter binding may be unavailable in pure Dart/unit-test contexts.
    return;
  }
}