BluetoothGattCharacteristic constructor

const BluetoothGattCharacteristic({
  1. required String uuid,
  2. required String serviceUuid,
  3. List<String> properties = const <String>[],
  4. List<String> permissions = const <String>[],
  5. List<int> value = const <int>[],
  6. List<BluetoothGattDescriptor> descriptors = const <BluetoothGattDescriptor>[],
  7. Map<String, dynamic> raw = const <String, dynamic>{},
})

创建 GATT 特征。

参数:

  • uuid:特征 UUID,无默认值。
  • serviceUuid:所属服务 UUID,无默认值。
  • properties:特征属性,默认 const <String>[]。常用值:readwritewriteWithoutResponsenotifyindicate。iOS/macOS 额外支持 notifyEncryptionRequiredindicateEncryptionRequired
  • permissions:本地 GATT Server 权限,默认 const <String>[]。为空时 Android/iOS/macOS 都会按可读可写处理;加密权限存在平台差异,跨平台推荐使用 readwrite
  • value:初始值,默认 const <int>[]
  • descriptors:描述符列表,默认 const <BluetoothGattDescriptor>[]
  • raw:原生完整字段,默认 const <String, dynamic>{}

Implementation

const BluetoothGattCharacteristic({
  required this.uuid,
  required this.serviceUuid,
  this.properties = const <String>[],
  this.permissions = const <String>[],
  this.value = const <int>[],
  this.descriptors = const <BluetoothGattDescriptor>[],
  this.raw = const <String, dynamic>{},
});