Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
danylo-safonov-solid committed Nov 16, 2023
1 parent ffe7f59 commit 9e2678b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/src/add_imports/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ class Config {
'file_url_prefix': String fileUrlPrefix,
} = loadYaml(yamlString) as YamlMap;

final classesMap = classesYamlMap.map(
(key, value) => MapEntry(
key as String,
ClassInteropData.fromYamlList(value as YamlList),
),
);
final classesMap = classesYamlMap
.cast<String, YamlList>()
.mapValues(ClassInteropData.fromYamlList);

return Config(
classesMap: classesMap,
Expand All @@ -49,3 +46,8 @@ class Config {
return 'import { $classname } from "$url";';
}
}

extension MapMapValues<K, V> on Map<K, V> {
Map<K, V1> mapValues<V1>(V1 Function(V) f) =>
map((k, v) => MapEntry(k, f(v)));
}

0 comments on commit 9e2678b

Please sign in to comment.