DartType.fromJson constructor

DartType.fromJson(
  1. dynamic json
)

Build a Dart type from a JSON string or map.

Implementation

factory DartType.fromJson(dynamic json) {
  if (json is String) {
    return DartType(name: json);
  } else if (json is Map<String, dynamic>) {
    return _$DartTypeFromJson(json);
  } else if (json is YamlMap) {
    return _$DartTypeFromJson({
      'name': json['name'],
      'imports': (json['imports'] as YamlList).map((s) => s).toList(),
    });
  } else {
    throw 'Invalid YAML: $json';
  }
}