add method

HDictBuilder add(
  1. String name, [
  2. Object? val,
  3. String? unit
])

Adds tag name and value, returns this.

If val is null name sets with marker value.

Implementation

HDictBuilder add(String name, [Object? val, String? unit]) {
  if (!HDict.isTagName(name)) {
    throw ArgumentError('Invalid tag name: $name');
  }

  if (val == null) {
    _add(name, HMarker.VAL);
  } else if (val is bool) {
    _add(name, HBool(val));
  } else if (val is num) {
    _add(name, HNum(val, unit));
  } else if (val is String) {
    _add(name, HStr(val));
  } else if (val is HVal) {
    _add(name, val);
  }

  return this;
}