Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the function of sidebar in Java

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report