The article is used to record attributes and use methods, to prevent forgetting later, you can come to find.

BottomNavigationBar

Create a way

class _TabbarsState extends State<Tabbars> { late int currentIndex = 0; final List list = [ SSLHome(), SSLCategory(), SSLSetting() ]; @override Widget build(BuildContext context) {return Scaffold(appBar: appBar (title: Text(' this is the first page '),) List [currentIndex], // Set bottom tabBar bottomNavigationBar: bottomNavigationBar (// Set the current subscript. CurrentIndex: currentIndex, // onTap: SetState (() {currentIndex = index; }); }, // size iconSize: 36, // select the color after the fixedColor: color. red, // set the name of the button and the icon items: const [BottomNavigationBarItem(icon: Icon(Icons. Home),label: 'home '), BottomNavigationBarItem(Icon: Icon(Icons. Category),label: BottomNavigationBarItem(icon: icon (Icons. Settings),label: 'set '),],),); }}Copy the code

Routing, which is the interface jump in iOS.

There are two types of routes: common routes and named routes.

Common routing

Navigator.of(context).push(MaterialPageRoute(Builder: (context)=> SSLSearch(title: 'This is the search interface ',));Copy the code

Just replace SSLSearch(title: ‘This is the search interface’) in the code above with your component (page). Very simple.

If there is a push, there must be a pop.

Navigator.of(context).pop();
Copy the code

After routing

Named routes do not transmit values. You can use it like this.

First, register the route at the entrance of the App.

main() { runApp(new MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { // TODO: Implement build return MaterialApp(home: const Tabbars(), title: 'This is the home page ', { '/search':(context)=>SSLSearch(), }, ); }}Copy the code

Replace SSLSearch() with your own page.

then

Navigator.of(context).pushNamed('/search');
Copy the code

Call the above code to jump to the specified interface.

For example, if the product list jumps to the product details, you need to pass productId.

The method of naming routes to transmit values.

Continue to register the route using the routes attribute.

class MyApp extends StatelessWidget { var routes = { '/search': (context) => SSLSearch(), }; @override Widget build(BuildContext context) { // TODO: implement build return MaterialApp( home: Const Tabbars(), title: 'this is the home page ', // register named routes: routes,); }}Copy the code

Then pass the value at the jump point

Navigator.of(context).pushnamed ('/search',arguments:" This is a title arguments");Copy the code

Receive values via modalroute.of (context)! . Settings. The arguments.

class SSLSearch extends StatefulWidget { @override State<SSLSearch> createState() => _SSLSearchState(); } class _SSLSearchState extends State<SSLSearch> { String title = ""; @override Widget build(BuildContext context) {// Receive value title = modalroute.of (context)! .settings.arguments as String; return Scaffold( floatingActionButton: FloatingActionButton( child: Text('adas'), onPressed: (){ Navigator.of(context).pop(); },), appBar: appBar (title: Text(title),), body: Text(' search interface '), backgroundColor: color.blue,); }}Copy the code