Script.fromJson constructor

Script.fromJson(
  1. String name,
  2. dynamic json, {
  3. List<String>? parents,
})

Implementation

factory Script.fromJson(String name, dynamic json, {List<String>? parents}) {
  final possibleCommands = tryReadListOrString(json);

  if (possibleCommands != null) {
    return Script.defaults(
      name: name,
      commands: possibleCommands,
      parents: parents,
    );
  }

  return _$ScriptFromJson(
    {
      ...?json as Map?,
      Keys.name: name,
      if (parents != null) Keys.parents: parents,
    },
  );
}