child: Text(
'Label/小标题',
),
),
],
),
),
drawerScrimColor: Colors.blue.withOpacity(0.6),
);
}
}
抽屉导航类型
Standard navigation drawer / 标准导航抽屉
可以同时点击抽屉导航和屏幕内容。
用途:平板和台式机。
由于屏幕尺寸有限,它们不适合移动设备。
class _MyHomePageState extends State {
@override
Widget build(BuildContext context) {
return Row(
children: [
Drawer(
child: ListView(
// Important: Remove any padding from the ListView.
padding: EdgeInsets.zero,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
'标准导航_顶部',
style: TextStyle(fontSize: 12.0),
),
),
Divider(
height: 1,
thickness: 1,
),
ListTile(
leading: Icon(Icons.favorite),
title: Text(
'标准导航_选项一',
style: TextStyle(fontSize: 10.0),
),
selected: _selectedDestination == 0,
onTap: () => selectDestination(0),
),
ListTile(
leading: Icon(Icons.delete),
title: Text(
'标准导航_选项二',
style: TextStyle(fontSize: 10.0),
),
selected: _selectedDestination == 1,
onTap: () => selectDestination(1),
),
ListTile(
leading: Icon(Icons.label),
title: Text(
'标准导航_选项三',
style: TextStyle(fontSize: 10.0),
),
selected: _selectedDestination == 2,
onTap: () => selectDestination(2),
),
Divider(
height: 1,
thickness: 1,
),
],
),
),
VerticalDivider(
width: 1,
thickness: 1,
),
Expanded(
child: Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Container(
child: Text(
'$_selectedDestination',
style: TextStyle(fontSize: 22.0, fontWeight: FontWeight.bold),
)),
),
)),
],
);
}
int _selectedDestination = 0;
void selectDestination(int index) {
setState(() {
_selectedDestination = index;
});
}
}
Modal navigation drawer / 模态导航抽屉
只可以点击导航栏,屏幕内容无法触摸
位于应用程序的UI之上,不会影响屏幕的布局。
class _MyHomePageState extends State {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Activity_PhoneWindow_DecorView'),
),
drawer: Drawer(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('This is the Drawer'),
ElevatedButton(
onPressed: null,
child: const Text('Close Drawer'),
),
],
),
),
),
body: Center(
child: Container(
width: double.infinity,
height: double.infinity,
color: Colors.green,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
_activity(),
Container(
padding: EdgeInsets.only(left: 10.0, top: 10.0),
margin: EdgeInsets.all(
20.0,
),
color: Colors.orange,
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height - 200.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_phoneWindow(),
_decorView(),
],
),
),
],
),
),
),
//child: Text.rich(TextSpan(text: 'final InlineSpan textSpan / The text to display as a [InlineSpan]')),
);
}
Container _decorView() {
return Container(
padding: EdgeInsets.only(left: 10.0, top: 10.0),
margin: EdgeInsets.all(
20.0,
),
color: Colors.redAccent,
width: MediaQuery.of(context).size.width - 80.0,
height: MediaQuery.of(context).size.height - 300.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'DecorView',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
color: Colors.white),
),
Container(
width: double.infinity,
padding: EdgeInsets.only(bottom: 10.0, top: 10.0),
margin: EdgeInsets.only(left: 10.0, top: 10.0, right: 20.0),
color: Colors.black.withOpacity(0.5),
alignment: Alignment.center,
child: Text(
'TitleView',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
color: Colors.white),
),
),
Expanded(
flex: 1,
child: GestureDetector(
onTap: () {
Navigator.of(context).pushNamed('/TwoPage');
},
child: Container(
width: double.infinity,
padding: EdgeInsets.only(bottom: 10.0, top: 10.0),
margin: EdgeInsets.only(
left: 10.0, top: 10.0, right: 20.0, bottom: 20.0),
color: Colors.black.withOpacity(0.5),
alignment: Alignment.center,
child: Text(
'ContentView',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
color: Colors.white),
),
),
),
),
],
),
);
}
Text _phoneWindow() {
return Text(
'PhoneWindow',
style: TextStyle(
fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.white),
);
}
Container _activity() {
return Container(
padding: EdgeInsets.only(left: 10.0, top: 10.0),
child: Text(
'Activity',
style: TextStyle(
fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.white),
),
);
}
}
Bottom navigation drawer / 底部导航栏
底部导航抽屉是固定在屏幕底部而不是左侧或右侧边缘的模式抽屉。
仅仅用于底部导航。
注意:Flutter 中没有底部抽屉,但是可以通过创建由ListTile、分隔符和文本小部件组成的自定义小部件来创建底部导航。
PositionedTransition 被用着抽屉动画的显示与隐藏。
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)

设计模式学习笔记
设计模式系列学习视频
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门即可获取!
60083540)]
[外链图片转存中…(img-ybcihoD6-1712260083541)]
[外链图片转存中…(img-3c9OQwfO-1712260083541)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)

设计模式学习笔记
[外链图片转存中…(img-GDscuz79-1712260083542)]
设计模式系列学习视频
[外链图片转存中…(img-MsEWMOji-1712260083542)]