getState method

Future<BluetoothState> getState()

Returns the current BluetoothState reported by the native Android plugin. Unknown values are mapped to BluetoothState.uknow.

Implementation

Future<BluetoothState> getState() async {
  try {
    final result = await _channel.invokeMethod<String>('getBluetoothState');
    return enumFromString(BluetoothState.values, result) ??
        BluetoothState.uknow;
  } catch (_) {
    return BluetoothState.uknow;
  }
}