in lib/src/pubspec.dart [176:212]
Map<String, VersionConstraint?>? _environmentMap(Map? source) =>
source?.map((k, value) {
final key = k as String;
if (key == 'dart') {
// github.com/dart-lang/pub/blob/d84173eeb03c3/lib/src/pubspec.dart#L342
// 'dart' is not allowed as a key!
throw CheckedFromJsonException(
source,
'dart',
'VersionConstraint',
'Use "sdk" to for Dart SDK constraints.',
badKey: true,
);
}
VersionConstraint? constraint;
if (value == null) {
constraint = null;
} else if (value is String) {
try {
constraint = VersionConstraint.parse(value);
} on FormatException catch (e) {
throw CheckedFromJsonException(source, key, 'Pubspec', e.message);
}
return MapEntry(key, constraint);
} else {
throw CheckedFromJsonException(
source,
key,
'VersionConstraint',
'`$value` is not a String.',
);
}
return MapEntry(key, constraint);
});