|
|
@ -1,4 +1,5 @@ |
|
|
import 'dart:async'; |
|
|
import 'dart:async'; |
|
|
|
|
|
import 'dart:io'; |
|
|
|
|
|
|
|
|
import 'package:device_jieli/device_jieli.dart'; |
|
|
import 'package:device_jieli/device_jieli.dart'; |
|
|
import 'package:flutter/material.dart'; |
|
|
import 'package:flutter/material.dart'; |
|
|
@ -310,6 +311,11 @@ class DevicesController extends GetxController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Future<bool> _ensureBluetoothPermission() async { |
|
|
Future<bool> _ensureBluetoothPermission() async { |
|
|
|
|
|
// iOS: CoreBluetooth 首次扫描时由系统自动弹出蓝牙权限对话框 |
|
|
|
|
|
// (依赖 Info.plist 的 NSBluetoothAlwaysUsageDescription), |
|
|
|
|
|
// permission_handler 的 bluetoothScan/bluetoothConnect 是 Android 专属, |
|
|
|
|
|
// 在 iOS 上调用永远返回 denied,会误拦截扫描。 |
|
|
|
|
|
if (Platform.isIOS) return true; |
|
|
try { |
|
|
try { |
|
|
final results = await [ |
|
|
final results = await [ |
|
|
Permission.bluetoothScan, |
|
|
Permission.bluetoothScan, |
|
|
|