简体   繁体   English

IOS Simulator 可以运行一个没有命名为 main.dart 的 dart 文件吗?

[英]Can IOS Simulator run a dart file that is not named main.dart?

I am currently trying to run an app where main.dart and screen.dart are in the same directory.我目前正在尝试运行 main.dart 和 screen.dart 位于同一目录中的应用程序。 However, when I test screen.dart using the simulator, it runs the main.dart但是,当我使用模拟器测试 screen.dart 时,它运行 main.dart

Similarly, when I move screen.dart to a separate directory and try running it there, my terminal says it cannot find main.dart同样,当我将 screen.dart 移动到一个单独的目录并尝试在那里运行它时,我的终端说它找不到 main.dart

Is there anyway to fix this or am I going about this the wrong way?有没有办法解决这个问题,还是我以错误的方式解决这个问题? I am trying to call screen.dart from the main.dart so I assumed it should be in the same directory.我试图从 main.dart 调用 screen.dart 所以我认为它应该在同一个目录中。 I've tried looking online but I am unsure if I am wording my question right and thought I'll ask here.我试过在网上查找,但我不确定我是否正确地表达了我的问题,并认为我会在这里问。 Thank you!谢谢!

在 flutter 中,您可以使用任何文件作为主文件,只需使用flutter run -t <file-path>即可运行flutter run -t screen.dart如果 screen.dart 直接位于 lib 文件夹中,则只需使用flutter run -t screen.dart ,如果不提供lib 文件夹的相对路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM