fix bluetooth device enumerate. (#281)
* fix bluetooth device enumerate. * update README.md * dart format. * revert pubspec.yaml. * fix analyzer.
This commit is contained in:
@@ -117,11 +117,36 @@ We require a set of permissions that need to be declared in your `AppManifest.xm
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
|
||||
...
|
||||
</manifest>
|
||||
```
|
||||
|
||||
For using the bluetooth headset correctly on the android device, you need to add `permission_handler` to your project.
|
||||
And call the following code after launching your app for the first time.
|
||||
|
||||
```dart
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
Future<void> _checkPremissions() async {
|
||||
var status = await Permission.bluetooth.request();
|
||||
if (status.isPermanentlyDenied) {
|
||||
print('Bluetooth Permission disabled');
|
||||
}
|
||||
status = await Permission.bluetoothConnect.request();
|
||||
if (status.isPermanentlyDenied) {
|
||||
print('Bluetooth Connect Permission disabled');
|
||||
}
|
||||
}
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await _checkPremissions();
|
||||
runApp(MyApp());
|
||||
}
|
||||
```
|
||||
|
||||
### Desktop support
|
||||
|
||||
In order to enable Flutter desktop development, please follow [instructions here](https://docs.flutter.dev/desktop#set-up).
|
||||
|
||||
Reference in New Issue
Block a user