BluetoothGattService.fromMap constructor

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

从原生 Map 创建 GATT 服务。

参数:

  • map:原生服务数据,无默认值。

Implementation

factory BluetoothGattService.fromMap(Map<String, dynamic> map) {
  final characteristics =
      (map['characteristics'] as List<dynamic>? ?? const <dynamic>[])
          .map(
            (item) => BluetoothGattCharacteristic.fromMap(_asStringMap(item)),
          )
          .toList(growable: false);
  return BluetoothGattService(
    uuid: map['uuid']?.toString() ?? '',
    isPrimary: _asBool(map['isPrimary'], defaultValue: true),
    characteristics: characteristics,
    includedServices: _asStringList(map['includedServices']),
    raw: map,
  );
}