【问题标题】:Flutter:Question regarding named and initial routeFlutter:关于命名和初始路由的问题
【发布时间】:2020-02-07 04:25:39
【问题描述】:

如果我使用命名路由和初始路由,则无法使用 home 参数,这是否意味着我必须在我为应用创建的每个新屏幕上创建 Scaffold 和 Material App Widget?

【问题讨论】:

    标签: android mobile flutter flutter-layout


    【解决方案1】:

    不,你不知道。举个例子

        class MyApp extends StatelessWidget {
      // This widget is the root of your application.
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          initialRoute: 'inicio',
          routes: <String, WidgetBuilder>{
            'tabs': (BuildContext context) => TabsPage(),
            'eventos': (BuildContext context) => EventosPage(),
            'agenda': (BuildContext context) => AgendaPage(),
            'sobre': (BuildContext context) => SobrePage(),
            'palestrantes': (BuildContext context) => PalestrantesPage(),
            'inicio': (BuildContext context) => InicioPage(),
            'hoteis': (BuildContext context) => HoteisPage(),
            'restaurantes': (BuildContext context) => RestaurantesPage(),
            'info': (BuildContext context) => InfoPage(),
            'homeParticipante': (BuildContext context) => HomeParticipante(),
            'qr': (BuildContext context) => QrPage(),
          },
          title: 'Siepex App',
        );
      }
    

    每条路由都返回一个小部件(通常是一个脚手架),它将作为一个子组件安装在 materialApp 上。

    【讨论】:

      猜你喜欢
      • 2019-12-06
      • 2019-01-25
      • 2023-03-05
      • 1970-01-01
      • 2011-03-15
      • 1970-01-01
      • 2019-06-21
      • 1970-01-01
      • 2023-03-10
      相关资源
      最近更新 更多