decodeJson method Null safety

  1. @override
void decodeJson(
  1. Map<String, dynamic> json,
  2. {required bool needsSave}
)
override

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

@override
void decodeJson(Map<String, dynamic> json, {required bool needsSave}) {
  super.decodeJson(json, needsSave: needsSave);
  memory.numRegisters = json['numRegisters'] as int;
  resultMatrix = json['resultMatrix'] as int;
  isComplexMode = getFlag(8);
  final ms = json['matrices'] as List;
  for (int i = 0; i < matrices.length; i++) {
    matrices[i].decodeJson(ms[i] as Map<String, dynamic>);
  }
  final Object? lastRandom = json['lastRandom'];
  if (lastRandom is double) {
    rand.setNoReseed(lastRandom);
  }
}