Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the function of sidebar in Java

Shulou Source: shulou.com Published: 2022-06-02 19:58:09 09月16日 Update

This article mainly explains "how to achieve the sidebar function of Java". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to achieve the sidebar function of Java".

Import 'package:flutter/material.dart';import' tabs/Home.dart';import 'tabs/Category.dart';import' tabs/Setting.dart';class Tabs extends StatefulWidget {final index; Tabs ({Key key, this.index = 0}): super (key: key); @ override _ TabsState createState () = > _ TabsState (this.index);} class _ TabsState extends State {int _ currentIndex = 0; _ TabsState (index) {this._currentIndex = index } / / put the page in the array List _ pageList = [HomePage (), CategoryPage (), SettingPage (),] @ override Widget build (BuildContext context) {return Scaffold (appBar: AppBar (title: Text),), body: this._ pageList [this. _ currentIndex], bottomNavigationBar: BottomNavigationBar (/ / which item currentIndex: this._currentIndex is selected by default / / Click on the navigation bar to get the index value onTap: (int index) {setState () {this._currentIndex = index }) }, / / iconSize: 30.0, / / icon size fixedColor: Colors.red, / / selected color type: BottomNavigationBarType.fixed, / / configure the bottom tabs can have multiple buttons / / define the navigation bar picture + name items: [BottomNavigationBarItem (icon: Icon (Icons.home), title: Text ("home page")) BottomNavigationBarItem (icon: Icon (Icons.category), title: Text ("classification"), BottomNavigationBarItem (icon: Icon (Icons.settings), title: Text ("setup"),],) / / here is the core code drawer: Drawer (child: Column (children: [Row (children: [Expanded (child: UserAccountsDrawerHeader (accountName: Text)), accountEmail: Text ("www.1342134929@qq.com") CurrentAccountPicture: CircleAvatar (backgroundImage: NetworkImage ("https://cache.yisu.com/upload/information/20200729/145/36557.jpg"),)) Decoration: BoxDecoration (image: DecorationImage (image: NetworkImage ("https://cache.yisu.com/upload/information/20200729/145/36557.jpg"), fit: BoxFit.cover,),))] ), ListTile (leading: CircleAvatar (child: Icon (Icons.home),), title: Text ("my Space"), onTap: () {Navigator.of (context) .pop () / / hide the sidebar Navigator.pushNamed (context,'/ NavBar') / / routing jump},), Divider (), ListTile (leading: CircleAvatar (child: Icon (Icons.people),), title: Text ("user Center"), Divider () ListTile (leading: CircleAvatar (child: Icon (Icons.settings),), title: Text ("setup Center"),),],),)) }} Thank you for your reading, the above is the content of "how to achieve the sidebar function of Java". After the study of this article, I believe you have a deeper understanding of how to achieve the sidebar function of Java, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Side function learning content home page navigation code name picture multiple size that is bottom idea situation button array article more core Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Huawei Microsoft vpn MySQL