fromJson static method Null safety

DisplayMode fromJson(
  1. dynamic val,
  2. bool isComplex
)

Implementation

static DisplayMode fromJson(dynamic val, bool isComplex) {
  for (final v in _intValues) {
    if (v._jsonName == val) {
      return v;
    }
  }
  if ((val as String).startsWith('f')) {
    return float(int.parse(val.substring(1)));
  } else if (val.startsWith('x')) {
    return fix(int.parse(val.substring(1)), isComplex);
  } else if (val.startsWith('s')) {
    return sci(int.parse(val.substring(1)), isComplex);
  } else if (val.startsWith('e')) {
    return eng(int.parse(val.substring(1)), isComplex);
  }
  throw ArgumentError('Bad DisplayMode:  $val');
}