简体   繁体   English

当我使用根名称导航时,如何在Flutter中创建全屏对话框?

[英]How to create full screen dialog in flutter when I am using root names to Navigate?

This is the sample code using rootName but here I am not able to use MaterialPageRoute to get the fullScreenDialog property. 这是使用rootName的示例代码,但是在这里,我无法使用MaterialPageRoute来获取fullScreenDialog属性。

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

Navigator 航海家

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

You can use something like this inside Material App. 您可以在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);

        }
      },
new MaterialApp(
    title: 'Named Routes Demo', 
    theme: ThemeData(
    primarySwatch: Colors.green), 
    initialRoute: '/', 
    onGenerateRoute: (RouteSettings settings) {
      List<String> pathElements = settings.name.split("/");
      if (pathElements[0] != "") return null;
      switch (pathElements[1]) {
        case "":
          return MaterialPageRoute(
              builder: (context) => FirstScreen());
        case "second":
          return MaterialPageRoute(
              builder: (context) => SecondScreen(), fullscreenDialog: true);
        case "third":
          return MaterialPageRoute(
              builder: (context) => ThirdScreen(), fullscreenDialog: true);
    }
  },
)

Navigator Button 导航按钮

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单击布局功能时如何显示全屏对话框或导航到其他屏幕? - How can I show full screen dialog or navigate to other screen when I click a Layout function? Flutter:如何使用DropDownMenuItems导航到新屏幕 - Flutter: How do I navigate to a new screen using DropDownMenuItems 使用全屏对话框时如何隐藏导航栏 - How to Hide Navigation Bar When Using Full Screen Dialog 如何在非全屏模式下创建透明对话框 - how to create transparent dialog NOT in full screen 使用 DialogFragment 和导航库时将对话框显示为全屏或对话框 - Show dialog as full screen or as dialog when using DialogFragment and Navigation Library 我正在调用自定义类别适配器。使用自定义适配器时如何在android中设置全屏背景 - I am calling custom category adapter.How to set background for full screen in android when using custom adapter 如何在android中创建自定义全屏ovarlay对话框 - How to create custom full screen ovarlay dialog in android Flutter:在滚动时将简单对话框转换为全屏对话框 - Flutter: Convert Simple Dialog To Full Screen Dialog On Scroll 如何使用对话框片段设置全屏对话框 - How to set Full screen dialog with dialog fragment 当通知到达时,如何在任何屏幕中显示自定义对话框? - How to show a custom dialog in any screen in when notification arrived flutter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM