[英]How do i use flutter variables from main.dart in other screen.dart files in the same lib folder?
[英]Flutter: How do I change main.dart(entry point) to some other page in Flutter?
- 我开始在 main.dart 中处理应用程序的“主页”。
- 然后我创建了“Login.dart”页面,现在我希望我的应用程序以“Login.dart”页面开始。
我是 Flutter 的新手。
-t
参数执行各种命令(运行、构建等)支持的操作
flutter run -t lib/my_other_main.dart
如果你想使用 lib/config/main_production.dart 以外的文件中的主入口点构建你的发布应用程序,你必须这样做:
flutter build apk -t lib/config/main_production.dart
在main.dart
您可以指定应用打开的第一个屏幕:
runApp(new MaterialApp(
debugShowCheckedModeBanner: false,
theme: //theme
title: "Title",
home: new Login(), //Here you can specify the screen the app starts on.
routes: <String, WidgetBuilder>{
//routes
},
));
我不确定这是否比 Günter 的答案更好,但我的意思是您不必在构建或运行时始终指定文件名。
flutter run -t lib/main_admin.dart
t
代表target,默认为lib/main.dart。 如果你不指定 -t 你会去 lib/main.dart
如果您想为相同的入口点加载不同的风格,您也可以将--flavor
传递给 flutter run 命令 - 即生产、开发和测试
我们有一个单独的文件。 请按照以下步骤操作:
1.转到测试>小部件.test.dart
2.将导入package:flutter_async/main.dart
改为package:flutter_async/your_file_name.dart
在您定义的类中,您可以使用MyApp ( runapp 函数将作为输入)类,或者您也可以将 Myapp 类重命名为 widget.testfile 中的其他类,作为您的应用程序的第一个屏幕。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.