代码之家  ›  专栏  ›  技术社区  ›  anticafe

如何在同一文件夹中导入多个Dart文件

  •  0
  • anticafe  · 技术社区  · 7 年前

    import 'screens/screen_1.dart'; import 'screens/screen_2.dart';... ),我要批量导入(例如 import 'screens/*.dart' )但没用。

    1 回复  |  直到 7 年前
        1
  •  9
  •   Günter Zöchbauer    7 年前

    Dart导入不支持同时导入多个文件。

    您可以做的是创建一个导出其他库的库

    screens.dart

    export 'screens/screen_1.dart';
    export 'screens/screen_2.dart';
    export 'screens/screen_3.dart';
    

    foo.dart

    import 'screens.dart';