MedicationPackage.fromYaml constructor

MedicationPackage.fromYaml(
  1. dynamic yaml
)

Factory constructor, accepts a String in YAML format as an argument

Implementation

factory MedicationPackage.fromYaml(dynamic yaml) => yaml is String
    ? MedicationPackage.fromJson(
        jsonDecode(jsonEncode(loadYaml(yaml))) as Map<String, dynamic>)
    : yaml is YamlMap
        ? MedicationPackage.fromJson(
            jsonDecode(jsonEncode(yaml)) as Map<String, dynamic>)
        : throw ArgumentError(
            'MedicationPackage cannot be constructed from input provided,'
            ' it is neither a yaml string nor a yaml map.');