Flutter : How do i change main.dart(entry point) to some other page in Flutter?

前端 未结 7 653
故里飘歌
故里飘歌 2020-12-16 15:08
  • I started working on the \"home page\" of the application in main.dart.
  • Then I created \"Login.dart\" page, and now i want my application t
相关标签:
7条回答
  • 2020-12-16 15:46

    Follow these pictures:

    be sure you write the right path:

    hint: ("lib/start.dart") just example.

    image(5) to test your new entrypoint:

    0 讨论(0)
  • 2020-12-16 15:47

    You can change your Dart entry point from edit configurations.

    Change your main.dart file to some other file.

    0 讨论(0)
  • 2020-12-16 15:52

    In your main.dart you can specify the first screen that your app opens to:

    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
      },
    ));
    

    I'm not sure if this is any better than Günter's answer, but mine will mean you don't have to always specify the file name when building or running.

    0 讨论(0)
  • 2020-12-16 15:58

    flutter run -t lib/main_admin.dart the t stands for target, the default of which is lib/main.dart. If you don't specify the -t you will go to lib/main.dart

    you can also pass in --flavor to the flutter run command if you would like to load a different flavour for your same entry point - ie production, dev & test

    0 讨论(0)
  • 2020-12-16 16:01

    We have a separate file for this. Please follow below steps:

    1.Go to test> widget.test.dart
    2.Change import package:flutter_async/main.dart to package:flutter_async/your_file_name.dart

    and in the class which you have defined you can use your MyApp (which runapp function will take as a input) class or you can rename Myapp class also to some other class from widget.testfile as a first screen for your app.

    0 讨论(0)
  • 2020-12-16 16:04

    The -t parameter does that which is supported by various commands (run, build, ...)

    flutter run -t lib/my_other_main.dart
    
    0 讨论(0)
提交回复
热议问题