loadJson method

  1. @override
void loadJson(
  1. Map<String, dynamic> decodedJson
)
override

Reconfigures this knob based on the provided deserialized JSON.

Implementation

@override
void loadJson(Map<String, dynamic> decodedJson) {
  // Preserve saved configurations from before static/runtime selection was
  // available, where the knob was directly represented by its value.
  if (decodedJson.containsKey('value')) {
    staticValueKnob.loadJson(decodedJson);
    modeKnob.value = StaticOrRuntimeIntMode.staticValue;
    return;
  }

  final modeJson = decodedJson['Mode'];
  if (modeJson is! Map) {
    throw RohdHclException('Static-or-runtime integer control has no mode.');
  }
  modeKnob.loadJson(Map<String, dynamic>.from(modeJson));

  final valueName = isRuntime ? 'Runtime Width' : 'Static Value';
  final valueJson = decodedJson[valueName];
  if (valueJson is! Map) {
    throw RohdHclException(
        'Static-or-runtime integer control has no "$valueName".');
  }
  if (isRuntime) {
    runtimeWidthKnob.loadJson(Map<String, dynamic>.from(valueJson));
  } else {
    staticValueKnob.loadJson(Map<String, dynamic>.from(valueJson));
  }
}