toJson method Null safety

Map<String, Object> toJson()

Convert to a data structure that can be serialized as JSON.

Implementation

Map<String, Object> toJson() {
  final r = <String, Object>{};
  r['version'] = _jsonVersion;
  r['modelName'] = modelName;
  r['settings'] = settings.toJson();
  final tm = trigMode.toJson();
  if (tm != null) {
    r['trigMode'] = tm;
  }
  r['displayMode'] = _displayMode.toJson();
  r['integerSignMode'] = _integerSignMode.toJson();
  r['wordSize'] = _wordSize;
  r['stack'] = _stack.map((v) => v.toJson()).toList();
  r['lastX'] = _lastX.toJson();
  if (isComplexMode) {
    r['imaginaryStack'] = _imaginaryStack!.map((v) => v.toJson()).toList();
    r['lastXImaginary'] = _lastXImaginary!.toJson();
  }
  r['flags'] = _flags;
  r['memory'] = memory.toJson();
  final debugLog = _debugLog;
  if (debugLog != null) {
    r['debugLog'] = debugLog.toJson();
    r['endDisplay'] = display.current;
  }
  return r;
}