更新
This commit is contained in:
@@ -69,7 +69,6 @@ class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
|
||||
}
|
||||
|
||||
Future<void> _requestBluetoothPermission() async {
|
||||
// Android 13+ 使用新的蓝牙权限
|
||||
Map<Permission, PermissionStatus> statuses = await [
|
||||
Permission.bluetoothScan,
|
||||
Permission.bluetoothConnect,
|
||||
@@ -113,7 +112,9 @@ class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
|
||||
|
||||
// 开始扫描蓝牙设备
|
||||
void _startScanning() async {
|
||||
if (!mounted) return;
|
||||
if (!mounted || isScanning) return;
|
||||
|
||||
_scanSubscription?.cancel();
|
||||
var bluetoothState = await FlutterBluePlus.isOn;
|
||||
if (!bluetoothState && !_isDialogShowing) {
|
||||
_isDialogShowing = true;
|
||||
@@ -131,6 +132,7 @@ class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
|
||||
// await FlutterBluePlus.startScan(timeout: Duration(minutes: 30));
|
||||
|
||||
_scanSubscription = FlutterBluePlus.scanResults.listen((results) {
|
||||
if (!mounted) return; // 确保页面未销毁
|
||||
final signalThreshold = blueteethBindController.model.singal!;
|
||||
final filteredResults = results
|
||||
.where((r) =>
|
||||
@@ -334,7 +336,7 @@ class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Text(
|
||||
'最小信号强度',
|
||||
'最小信号强度'.tr,
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
@@ -415,7 +417,7 @@ class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
|
||||
Expanded(
|
||||
child: Container(
|
||||
width: 100.rpx,
|
||||
height: 100.rpx,
|
||||
height: 80.rpx,
|
||||
decoration: BoxDecoration(
|
||||
color: FlutterFlowTheme.of(context)
|
||||
.secondaryBackground,
|
||||
@@ -519,7 +521,7 @@ class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'搜索',
|
||||
'搜索'.tr,
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
@@ -547,7 +549,8 @@ class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
|
||||
EdgeInsetsDirectional.fromSTEB(19.rpx, 0, 0, 0),
|
||||
child: Obx(() {
|
||||
return Text(
|
||||
'匹配出的外围设备(${blueteethBindController.model.betDevicelist!.length})',
|
||||
'匹配出的外围设备'.tr +
|
||||
"(${blueteethBindController.model.betDevicelist!.length})",
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
|
||||
Reference in New Issue
Block a user