apply method
These options with the key = value pairs of text set.
Implementation
SiOptions apply(String? text) {
if (text == null || text.trim().isEmpty) return this;
final keys = {..._keys};
var per = perMode;
for (final (rawKey, rawValue) in _keyValues(text)) {
for (final (key, value) in _normalise(rawKey, rawValue ?? 'true')) {
keys[key] = value;
if (key == 'per-mode') {
per = switch (value) {
'symbol' ||
'repeated-symbol' ||
'symbol-or-fraction' => PerMode.symbol,
'fraction' => PerMode.fraction,
_ => PerMode.power,
};
}
}
}
return SiOptions._(
per,
keys,
_units,
_unitOptions,
_prefixes,
_qualifiers,
_powers,
);
}