【问题标题】:What's the first page (Dart file) will run in Flutter App when I launch当我启动时,第一页(Dart 文件)将在 Flutter App 中运行
【发布时间】:2020-07-02 21:11:44
【问题描述】:

我编写了一个包含多个 dart 文件的颤振应用程序。但是 apk 包如何决定,当应用程序在手机上启动时首先运行哪个 dart 文件?我的意思是我想将一个 dart 文件设置为我的应用程序的主页/主页,并且我想先运行它。如何设置?

【问题讨论】:

  • 看看this question
  • 仔细阅读flutter build apk -h命令的输出

标签: flutter


【解决方案1】:

ma​​in.dart 文件上使用类似的东西

main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: appThemeData(),
      title: 'YOUR_APP_NAME',
      initialRoute: '/',
      routes: {
        '/': (context) => LoginPage(),
        '/mainMenu': (context) => MainMenu(),
        '/splash': (context) => SplashScreen(),

      },

    );
  }
}

【讨论】:

    猜你喜欢
    • 2018-10-27
    • 1970-01-01
    • 2023-04-08
    • 2018-03-11
    • 2021-04-05
    • 1970-01-01
    • 1970-01-01
    • 2018-10-22
    • 1970-01-01
    相关资源
    最近更新 更多