getMap<K, V> method

Map<K, V> getMap<K, V>(
  1. int tagId, {
  2. bool allowNull = true,
})

Implementation

Map<K, V> getMap<K, V>(int tagId, {bool allowNull = true}) {
  final result = where((element) => element.tagNumber == tagId);
  if (result.isEmpty && !allowNull) {
    throw TronPluginException(
      'field id does not exist.',
      details: {'fieldIds': map((e) => e.tagNumber).join(', '), 'id': tagId},
    );
  }
  final Map<K, V> data = {};
  for (final i in result) {
    final decode = TronProtocolBufferDecoder.decode(i.value);
    data.addAll({decode.getField<K>(1): decode.getField<V>(2)});
  }
  return data;
}