decodeJson method Null safety

void decodeJson(
  1. Map<String, dynamic> json
)

Must be called after the register storage has been read in, so any stray data will be properly zeroed out.

Implementation

void decodeJson(Map<String, dynamic> json) {
  int n = (json['lines'] as num).toInt();
  if (n < 0 || n > memory.totalNybbles ~/ 2) {
    throw ArgumentError('$n:  Illegal number of lines');
  }
  _lines = n;
  _extendedLines = 0;
  // Check for illegal instructions
  try {
    for (_currentLine = 1; _currentLine <= _lines; _currentLine++) {
      final instr = getCurrent();
      if (instr.isExtended) {
        _extendedLines++;
      }
    }
    _currentLine = 0;
  } catch (e) {
    _lines = 0;
    _currentLine = 0;
    rethrow;
  }
  n = (json['currentLine'] as num).toInt();
  if (n < 0 || n > _lines) {
    n = 0;
  }
  _currentLine = n;

  final returnStack = (json['returnStack'] as List<dynamic>?);
  if (returnStack != null && returnStack.length == _returnStack.length) {
    for (int i = 0; i < returnStack.length; i++) {
      _returnStack[i] = returnStack[i] as int;
    }
  }
  final returnStackPos = (json['returnStackPos'] as num?);
  if (returnStackPos != null) {
    _returnStackPos = returnStackPos.toInt();
  }
}