首页 > 解决方案 > 当我启动时,第一页(Dart 文件)将在 Flutter App 中运行

问题描述

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

标签: flutter

解决方案


在main.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(),

      },

    );
  }
}

推荐阅读