Prechádzať zdrojové kódy

fix: 修复part of导入包识别问题

hwh97 4 rokov pred
rodič
commit
d3affe446c

+ 8 - 3
lib/generator/router_generator.dart

@@ -48,23 +48,28 @@ class RouterGenerator extends GeneratorForAnnotation<RouterPage> {
               // 添加到imports
               for (LibraryElement element
                   in (await buildStep.inputLibrary).importedLibraries) {
-                Uri importUri = element.getType(importType)?.source?.uri;
+                if (element.name == "dart.core") {
+                  continue;
+                }
+                ClassElement importUri = element.getType(importType);
 
                 if (importUri != null) {
-                  router.imports.add(importUri.toString());
+                  router.imports.add(element.source?.uri.toString());
+                  break;
                 } else {
                   // 查找exports
                   Set<LibraryElement> exports = allExportedElements(element);
                   bool exported = false;
                   for (LibraryElement exportElement in exports) {
-                    print("export element ${exportElement.source?.uri}");
                     if (exportElement.getType(importType) != null) {
                       exported = true;
                       break;
                     }
                   }
+
                   if (exported) {
                     router.imports.add(element.source?.uri?.toString());
+                    break;
                   }
                 }
               }

+ 1 - 2
lib/util/utils.dart

@@ -27,8 +27,7 @@ bool isSpeciousType(String type) {
       type == "bool" ||
       type == "dynamic" ||
       type == "List" ||
-      type == "Map" ||
-      type == "dynamic") {
+      type == "Map") {
     return false;
   }
   return true;