requestBluetoothPermission method

Future<void> requestBluetoothPermission()

requestBluetoothPermission() is a function that requests bluetooth permission from the user using the permission_handler package

Implementation

Future<void> requestBluetoothPermission() async {
  if (Platform.isAndroid) {
    Map<Permission, PermissionStatus> status = await [
      Permission.bluetoothScan,
      Permission.bluetoothConnect
    ].request();
    bluetoothIsGranted =
        status[Permission.bluetoothScan] == PermissionStatus.granted &&
            status[Permission.bluetoothConnect] == PermissionStatus.granted;
  } else if (Platform.isIOS) {
    Map<Permission, PermissionStatus> status =
        await [Permission.bluetooth].request();
    bluetoothIsGranted =
        status[Permission.bluetooth] == PermissionStatus.granted;
  }
}