Browse Source

修正报错,升级1.0.4

Kevin 5 years ago
parent
commit
9363e23151
3 changed files with 9 additions and 9 deletions
  1. 6 6
      lib/bluetooth_device.dart
  2. 2 2
      lib/bluetooth_socket.dart
  3. 1 1
      pubspec.yaml

+ 6 - 6
lib/bluetooth_device.dart

@@ -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");

+ 2 - 2
lib/bluetooth_socket.dart

@@ -26,12 +26,12 @@ class BluetoothSocket {
   }
 
   write(Uint8List data) async {
-    await FlutterBluetooth._channel.invokeMethod(
+    await FlutterBluetooth.instance._channel.invokeMethod(
         'write', {'address': address, 'uuid': uuid, 'data': data});
   }
 
   close() async {
-    await FlutterBluetooth._channel
+    await FlutterBluetooth.instance._channel
         .invokeMethod('close', {'address': address, 'uuid': uuid});
   }
 

+ 1 - 1
pubspec.yaml

@@ -1,6 +1,6 @@
 name: flutter_bluetooth
 description: 传统蓝牙
-version: 1.0.3
+version: 1.0.4
 author:
 homepage: