BluetoothAdvertisementData constructor

const BluetoothAdvertisementData({
  1. String? localName,
  2. bool includeDeviceName = false,
  3. bool includeTxPowerLevel = false,
  4. List<String> serviceUuids = const <String>[],
  5. Map<int, List<int>> manufacturerData = const <int, List<int>>{},
  6. Map<String, List<int>> serviceData = const <String, List<int>>{},
})

创建广播数据。

参数:

  • localName:广播本地名称,默认 null。iOS/macOS 当前只使用该字段和 serviceUuids
  • includeDeviceName:是否包含适配器设备名,默认 false;Android 支持,iOS/macOS 忽略。
  • includeTxPowerLevel:是否包含发射功率,默认 false;Android 支持,iOS/macOS 忽略。
  • serviceUuids:广播服务 UUID,默认 const <String>[]。跨平台推荐只放必要服务。
  • manufacturerData:厂商数据,默认 const <int, List<int>>{};Android 支持,iOS/macOS 当前忽略。
  • serviceData:服务数据,默认 const <String, List<int>>{};Android 支持,iOS/macOS 当前忽略。

推荐:传统广播数据空间有限,优先保留 localName 和关键 serviceUuids,避免同时开启 includeDeviceName 和大量厂商数据导致 Android 广播启动失败。

Implementation

const BluetoothAdvertisementData({
  this.localName,
  this.includeDeviceName = false,
  this.includeTxPowerLevel = false,
  this.serviceUuids = const <String>[],
  this.manufacturerData = const <int, List<int>>{},
  this.serviceData = const <String, List<int>>{},
});