merge method
Siehe PosBusinessSettings.merge; shortcuts wird je Aktion gemischt.
Implementation
PosDeviceSettings merge(Map<String, dynamic> patch) {
_pruefeAenderung(
'device', patch, {..._geraetSchluessel, ...posDeviceOptionalFields, ...posDeviceOptionalSwitches, ...posDeviceOptionalChoices}, legacyDeviceKeys);
// Die optionale Lade hat keinen Standardwert, den `_mische` fortschreiben
// koennte: sie wird getrennt gefuehrt, `null` entfernt die Zuordnung.
final lade = patch.containsKey('drawerId') ? patch['drawerId'] : drawerId;
if (lade != null && !isPosOptionalId(lade)) {
throw ArgumentError('device.drawerId: keine Kennung (1-64 Zeichen aus A-Z a-z 0-9 _ -)');
}
// Ebenso die Spaltenbreite: `null` entfernt sie.
final breite = patch.containsKey('cartWidth') ? patch['cartWidth'] : toJson()['cartWidth'];
_pruefeWahlfeld('device', 'cartWidth', breite);
// Die optionalen Schalter ebenso: nur Wahrheitswert, `null` entfernt sie.
final aktuell = toJson();
final schalter = <String, Object?>{
for (final k in posDeviceOptionalSwitches) k: patch.containsKey(k) ? patch[k] : aktuell[k],
};
for (final e in schalter.entries) {
if (e.value != null && e.value is! bool) {
throw ArgumentError('device.${e.key}: true oder false erwartet');
}
}
final weg = {'drawerId', ...posDeviceOptionalSwitches, ...posDeviceOptionalChoices};
final json = _mische(toJson()..removeWhere((k, _) => weg.contains(k)), {...patch}..removeWhere((k, _) => weg.contains(k)));
return PosDeviceSettings.fromJson({
...json,
'drawerId': lade,
'cartWidth': ?breite,
for (final e in schalter.entries) e.key: ?e.value,
});
}