|
@@ -15,9 +15,9 @@ class BluetoothDevice {
|
|
|
|
|
|
static Future<BluetoothDevice> fromAddress(String address) async {
|
|
|
String name =
|
|
|
- await FlutterBluetooth._channel.invokeMethod('getName', address);
|
|
|
+ await FlutterBluetooth.instance._channel.invokeMethod('getName', address);
|
|
|
int deviceClass =
|
|
|
- await FlutterBluetooth._channel.invokeMethod('getDeviceClass', address);
|
|
|
+ await FlutterBluetooth.instance._channel.invokeMethod('getDeviceClass', address);
|
|
|
|
|
|
return BluetoothDevice(
|
|
|
address: address,
|
|
@@ -26,15 +26,15 @@ class BluetoothDevice {
|
|
|
}
|
|
|
|
|
|
Future<bool> isBond() async {
|
|
|
- return FlutterBluetooth._channel.invokeMethod('isBond', address);
|
|
|
+ return FlutterBluetooth.instance._channel.invokeMethod('isBond', address);
|
|
|
}
|
|
|
|
|
|
Future<bool> createBond() async {
|
|
|
- return FlutterBluetooth._channel.invokeMethod('createBond', address);
|
|
|
+ return FlutterBluetooth.instance._channel.invokeMethod('createBond', address);
|
|
|
}
|
|
|
|
|
|
Future<BluetoothSocket> createSocket(String uuid) async {
|
|
|
- await FlutterBluetooth._channel.invokeMethod('createSocket', {
|
|
|
+ await FlutterBluetooth.instance._channel.invokeMethod('createSocket', {
|
|
|
'address': address,
|
|
|
'uuid': uuid
|
|
|
});
|
|
@@ -44,7 +44,7 @@ class BluetoothDevice {
|
|
|
Future<List<String>> getUUIDs() async{
|
|
|
var isBond = await this.isBond();
|
|
|
if(isBond){
|
|
|
- List uuids = await FlutterBluetooth._channel.invokeMethod('getUUIDs', address);
|
|
|
+ List uuids = await FlutterBluetooth.instance._channel.invokeMethod('getUUIDs', address);
|
|
|
return uuids.map((item)=>item as String).toList();
|
|
|
}else{
|
|
|
throw ErrorDescription("只有配对蓝牙后才可以获取UUID");
|