21Flutter Drawer侧边栏、以及侧边栏内容布局
2024-08-31 07:31:50
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 = }) : super(key: key);
_TabsState createState() => _TabsState(this.index);
} class _TabsState extends State<Tabs> {
int _currentIndex = ;
_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('右侧侧边栏'),
),
);
}
}
最新文章
- Windows 2008 - 由于管理员设置的策略,该磁盘处于脱机状态
- javascript执行环境(执行期上下文)详解
- Linux0.11内核--系统调用机制分析
- React阶段开发总结
- BootStrap安装
- unity button
- 剑指offer系列54---数组中出现次数超过一半的数
- 机器学习 —— log-linear 模型
- 130道ASP.NET面试题
- Actor模型
- 判断两条直线的位置关系 POJ 1269 Intersecting Lines
- “海市蜃楼”般的逛街体验——VR全景智慧城市常诚
- 计算机网络之IP地址
- Struts2技术内幕 读书笔记二 web开发的基本模式
- PHP算法学习(4) 随机算法
- ELK收集tomcat状态日志
- Java面试题全集(上)转载
- 解析 ViewTreeObserver 源码(上)
- 运行Python出错,提示“丢失api-ms-win-crt-runtime-l1-1-0.dll”
- Android R文件介绍