BluetoothGattServerRequest.fromMap constructor

BluetoothGattServerRequest.fromMap(
  1. Map<String, dynamic> map
)

从原生 Map 创建 GATT Server 请求事件。

参数:

  • map:原生事件数据,无默认值。

Implementation

factory BluetoothGattServerRequest.fromMap(Map<String, dynamic> map) {
  return BluetoothGattServerRequest(
    event: map['event']?.toString() ?? '',
    deviceId: map['deviceId']?.toString() ?? '',
    serviceUuid: map['serviceUuid']?.toString(),
    characteristicUuid: map['characteristicUuid']?.toString(),
    descriptorUuid: map['descriptorUuid']?.toString(),
    requestId: (map['requestId'] as num?)?.toInt(),
    offset: (map['offset'] as num?)?.toInt() ?? 0,
    value: _asByteList(map['value']),
    preparedWrite: _asBool(map['preparedWrite']),
    responseNeeded: _asBool(map['responseNeeded']),
    raw: map,
  );
}