part of flutter_bluetooth; class BluetoothDevice { final String name; final String address; final int deviceClass; BluetoothDevice({this.name, this.address, this.deviceClass}); static BluetoothDevice fromJson(data) { String name = data['name']; String address = data['address']; int deviceClass = data['deviceClass']; return BluetoothDevice(name: name, address: address, deviceClass: deviceClass); } static Future fromAddress(String address) async { String name = await FlutterBluetooth._channel.invokeMethod('getName', address); int deviceClass = await FlutterBluetooth._channel.invokeMethod('getDeviceClass', address); return BluetoothDevice( address: address, name: name, deviceClass: deviceClass); } Future isBond() async { return FlutterBluetooth._channel.invokeMethod('isBond', address); } Future createBond() async { return FlutterBluetooth._channel.invokeMethod('createBond', address); } Future createSocket(String uuid) async { await FlutterBluetooth._channel.invokeMethod('createSocket', { 'address': address, 'uuid': uuid }); return BluetoothSocket._(address, uuid); } Future> getUUIDs() async{ var isBond = await this.isBond(); if(isBond){ List uuids = await FlutterBluetooth._channel.invokeMethod('getUUIDs', address); return uuids.map((item)=>item as String).toList(); }else{ throw ErrorDescription("只有配对蓝牙后才可以获取UUID"); } } bool operator ==(target){ if(target is BluetoothDevice){ return this.address == target.address; }else{ return false; } } @override // TODO: implement hashCode int get hashCode => this.address.hashCode; }