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

It obtains the route table based on the context, and then navigates to the predefined page based on the route name.

Another method

Without defining a route table, directly

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

This method is not as intuitive as using a route table, but it is convenient for passing parameters.

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

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