Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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');
},
like image 787
Smruti Ranjan Rana Avatar asked Oct 26 '25 08:10

Smruti Ranjan Rana


1 Answers

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

        }
      },
like image 169
Pawann Kumaarr Avatar answered Oct 28 '25 21:10

Pawann Kumaarr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!