From 9e2678b777892c453c38816d8776d5d6fd33e82b Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 16 Nov 2023 13:40:51 +0200 Subject: [PATCH] refactor --- lib/src/add_imports/config.dart | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/src/add_imports/config.dart b/lib/src/add_imports/config.dart index d4ee743..a88ca2d 100644 --- a/lib/src/add_imports/config.dart +++ b/lib/src/add_imports/config.dart @@ -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() + .mapValues(ClassInteropData.fromYamlList); return Config( classesMap: classesMap, @@ -49,3 +46,8 @@ class Config { return 'import { $classname } from "$url";'; } } + +extension MapMapValues on Map { + Map mapValues(V1 Function(V) f) => + map((k, v) => MapEntry(k, f(v))); +}