toJson method Null safety

Map<String, dynamic> toJson(
  1. {bool comments = false}
)

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

Implementation

Map<String, dynamic> toJson({bool comments = false}) {
  final r = <String, dynamic>{};
  if (comments) {
    r['comments'] = _comments;
  }
  r['version'] = _jsonVersion;
  r['settings'] = settings.toJson(comments: comments);
  r['displayMode'] = _displayMode.toJson();
  r['integerSignMode'] = _integerSignMode.toJson();
  r['wordSize'] = _wordSize;
  r['stack'] = _stack.map((v) => v.toJson()).toList();
  r['lastX'] = _lastX.toJson();
  r['flags'] = _flags;
  r['memory'] = memory.toJson(comments: comments);
  final debugLog = _debugLog;
  if (debugLog != null && comments) {
    r['debugLog'] = debugLog.toJson(comments: comments);
    r['endDisplay'] = display.current;
  }
  return r;
}