更新棉花糖
This commit is contained in:
36
lib/pages/mh_page/device/model/BlueToothDataModel.dart
Normal file
36
lib/pages/mh_page/device/model/BlueToothDataModel.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
|
||||
class BlueToothDataModel {
|
||||
String name;
|
||||
bool bind;
|
||||
String mac;
|
||||
ScanResult scanResult;
|
||||
String macA;
|
||||
String macB;
|
||||
int type;
|
||||
|
||||
BlueToothDataModel({
|
||||
this.name = '',
|
||||
required this.bind,
|
||||
required this.mac,
|
||||
required this.scanResult,
|
||||
required this.type,
|
||||
this.macA = '',
|
||||
this.macB = '',
|
||||
});
|
||||
|
||||
factory BlueToothDataModel.fromScanResult(ScanResult result,int type,
|
||||
{bool bind = false, String name = '', String mac = ''}) {
|
||||
// 如果外部没有传入 name,则取 localName
|
||||
String finalName =
|
||||
name.isNotEmpty ? name : (result.advertisementData.localName ?? '');
|
||||
|
||||
return BlueToothDataModel(
|
||||
name: finalName,
|
||||
bind: bind,
|
||||
mac: mac,
|
||||
scanResult: result,
|
||||
type:type
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user