当我使用根名称导航时,如何在Flutter中创建全屏对话框? [英] How to create full screen dialog in flutter when I am using root names to Navigate?

查看:42
本文介绍了当我使用根名称导航时,如何在Flutter中创建全屏对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是使用rootName的示例代码,但是在这里,我无法使用MaterialPageRoute来获取fullScreenDialog属性.

This is the sample code using rootName but here I am not able to use MaterialPageRoute to get the fullScreenDialog property.

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      initialRoute: '/',
      routes: {
        '/': (context) => MyHomePage(),
        '/under-development': (context) => UnderDevelopment(),
        '/profile1': (context) => Profile1()
      },
      title: appName,
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
          primaryColor: primaryColor,
          accentColor: secondaryColor,
          fontFamily: 'Poppins'),
    );
  }
}

导航器

onTap: () {
    Navigator.pushNamed(context, '/profile1');
},

推荐答案

您可以在Material App中使用类似的方法.希望对您有帮助.

You can use something like this inside Material App. I hope it helps.

onGenerateRoute: (RouteSettings settings) {
        List<String> pathElements = settings.name.split("/");
        if (pathElements[0] != "") return null;
        switch (pathElements[1]) {
          case "home":
          String userID = pathElements[2];  
            return MaterialPageRoute(
        builder: (context) => ReportsPage(
              userID: userID,
            ),fullscreenDialog: true);

        }
      },

这篇关于当我使用根名称导航时,如何在Flutter中创建全屏对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆