21Flutter Drawer侧边栏、以及侧边栏内容布局
Tabs.dart
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 = 1}) : super(key: key); _TabsState createState() => _TabsState(this.index); } class _TabsState extends State<Tabs> { int _currentIndex = 0; _TabsState(index) { this._currentIndex = index; } List _pageList = [HomePage(), CategoryPage(), SettingPage()]; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Flutter Demo'), ), bottomNavigationBar: BottomNavigationBar( currentIndex: this._currentIndex, onTap: (int index) { // print(index); setState(() { this._currentIndex = index; }); }, iconSize: 36.0, type: BottomNavigationBarType.fixed, fixedColor: Colors.red, items: [ BottomNavigationBarItem(icon: Icon(Icons.home), title: Text('首页')), BottomNavigationBarItem( icon: Icon(Icons.category), title: Text('分类')), BottomNavigationBarItem( icon: Icon(Icons.settings), title: Text('设置')), ]), body: this._pageList[this._currentIndex], drawer: Drawer( child: Column( children: <Widget>[ Row( children: <Widget>[ // Expanded( // child: DrawerHeader( // child: Text('你好Flutter'), // decoration: BoxDecoration( // // color: Colors.yellow // image: DecorationImage( // image: NetworkImage('https://www.itying.com/images/flutter/2.png'), // fit:BoxFit.cover // ), // ), // ) // ) Expanded( child: UserAccountsDrawerHeader( accountName: Text('老师你好'), accountEmail: Text('gztt@163.com'), currentAccountPicture: CircleAvatar( backgroundImage: NetworkImage( 'https://www.itying.com/images/flutter/3.png'), ), decoration: BoxDecoration( // color: Colors.yellow image: DecorationImage( image: NetworkImage( 'https://www.itying.com/images/flutter/2.png'), fit: BoxFit.cover), ), otherAccountsPictures: <Widget>[ Image.network( 'https://www.itying.com/images/flutter/5.png'), Image.network( 'https://www.itying.com/images/flutter/4.png') ], ), ) ], ), ListTile( leading: CircleAvatar( child: Icon(Icons.home), ), title: Text('我的空间')), Divider(), ListTile( leading: CircleAvatar( child: Icon(Icons.home), ), title: Text('用户中心'), onTap: () { Navigator.of(context).pop(); Navigator.pushNamed(context, '/user'); } ), Divider(), ListTile( leading: CircleAvatar( child: Icon(Icons.home), ), title: Text('用户中心'), ) ], ), ), endDrawer: Drawer( child: Text('右侧侧边栏'), ), ); } }
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术