turnOff static method

  1. @Deprecated('Deprecated in Android SDK 33 with no replacement')
Future<void> turnOff({
  1. int timeout = 10,
})

Turn off Bluetooth (Android only),

Implementation

@Deprecated('Deprecated in Android SDK 33 with no replacement')
static Future<void> turnOff({int timeout = 10}) async {
  var responseStream =
      FlutterBluePlusPlatform.instance.onAdapterStateChanged.where((p) => p.adapterState == BmAdapterStateEnum.off);

  // Start listening now, before invokeMethod, to ensure we don't miss the response
  Future<BmBluetoothAdapterState> futureResponse = responseStream.first;

  // invoke
  bool changed = await _invokePlatform(() => FlutterBluePlusPlatform.instance.turnOff(BmTurnOffRequest()));

  // only wait if bluetooth was on
  if (changed) {
    await futureResponse.fbpTimeout(timeout, "turnOff");
  }
}