decodeJson method Null safety
Convert from a data structure that comes from JSON. If there's an error in the middle, it might be partially read, but not in a way that causes bad behavior in the calculator.
Implementation
void decodeJson(Map<String, dynamic> json) {
menuEnabled.value = json['menuEnabled'] as bool;
_windowEnabled = json['windowEnabled'] as bool;
_euroComma = json['euroComma'] as bool;
_hideComplement = json['hideComplement'] as bool? ?? false;
_showWordSize = json['showWordSize'] as bool? ?? false;
_integerModeCommas = json['integerModeCommas'] as bool? ?? false;
showAccelerators.value = json['showAccelerators'] == true; // could be null
_msPerInstruction = (json['msPerInstruction'] as num?)?.toDouble();
_traceProgramToStdout = (json['traceProgramToStdout'] as bool?) ?? false;
_systemOverlaysDisabled =
(json['systemOverlaysDisabled'] as bool?) ?? false;
setPlatformOverlays();
int? ov = json['orientation'] as int?;
if (ov == null || ov < 0 || ov > OrientationSetting.values.length) {
_orientation = OrientationSetting.auto;
} else {
_orientation = OrientationSetting.values[ov];
}
_setPlatformOrientation();
_traceProgramToStdout = (json['traceProgramToStdout'] as bool?) ?? false;
fKeyColor = json['fKeyColor'] as int?;
fTextColor = json['fTextColor'] as int?;
gKeyColor = json['gKeyColor'] as int?;
gTextColor = json['gTextColor'] as int?;
lcdBackgroundColor = json['lcdBackgroundColor'] as int?;
lcdForegroundColor = json['lcdForegroundColor'] as int?;
}