banner
RustyNail

RustyNail

coder. 【blog】https://rustynail.me 【nostr】wss://ts.relays.world/ wss://relays.world/nostr

Page navigation in Flutter

One method is

new MaterialApp(
      title: '',
      theme: new ThemeData(
        primarySwatch: Colors.cyan,
      ),
      home: new MyHomePage(title: ''),
       routes: {
         '/sortiePage': (BuildContext con)=> new SortiePage()
       },
    );

First, define the names of the routes and the pages to navigate to in the app.

Then,

Navigator.of(context).pushNamed("routeName");

This will display the predefined page based on the route name obtained from the route table using the context.

Another method

Instead of defining a route table, directly use:

Navigator.push(
   context, 
   MaterialPageRoute(
     builder: (context){
       return new SortiePage(
         args: your args data,
       );
     }
   ) 
);

This method may not be as intuitive as using a route table, but it makes passing arguments easier.

One advantage of writing in Dart compared to Android is that you don't have to deal with bundling data.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.