Settings.fromJson constructor
Settings.fromJson(
- Map json
Implementation
factory Settings.fromJson(Map json) {
final settings = _$SettingsFromJson(json);
final patterns = <String, List<String>>{};
for (var e in settings.exclude) {
patterns.putIfAbsent(e, () => []).add('exclude');
}
for (var e in settings.include) {
patterns.putIfAbsent(e, () => []).add('include');
}
// make sure that the priorities patterns are valid regex
for (final MapEntry(key: pattern, value: locations) in patterns.entries) {
try {
RegExp(pattern);
} catch (error) {
throw ArgumentError.value(
pattern,
'Found in ${locations.join(',')}',
error,
);
}
}
return settings;
}