getState method

Future<BluetoothState> getState()

Returns the current BluetoothState of the device.

Throws if the host platform is not Android, iOS or macOS.

Implementation

Future<BluetoothState> getState() async {
  try {
    if (Platform.isAndroid) {
      return await bmAndroid.getState();
    } else if (Platform.isIOS) {
      return await bmIOS.getState();
    } else if (Platform.isMacOS) {
      return await bmMacOS.getState();
    } else {
      throw '[get_state] platform_not_supported - only Android, iOS and macOS are supported';
    }
  } catch (e) {
    rethrow;
  }
}