import 'package:flutter/material.dart';
import 'each_view.dart'; class BottomAppBarDemo extends StatefulWidget {
_BottomAppBarDemoState createState() => _BottomAppBarDemoState();
} class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
List<Widget> _eachView; //创建视图数组
int _index = 0; //数组索引,通过改变索引值改变视图 @override
void initState() {
// TODO: implement initState
super.initState();
_eachView = List();
_eachView
..add(EachView('Home'))
..add(EachView('Home1'))
..add(EachView('Home2'))
..add(EachView('Home3'))
..add(EachView('Home4'));
} @override
Widget build(BuildContext context) {
return Scaffold(
body: _eachView[_index],
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.of(context)
.push(MaterialPageRoute(builder: (BuildContext context) {
return EachView('New Page');
}));
},
tooltip: 'Increment',
child: Icon(
Icons.add,
color: Colors.white,
),
backgroundColor: Colors.green,
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: BottomAppBar(
color: Colors.white,
shape: CircularNotchedRectangle(),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[ IconButton(
icon: Icon(Icons.accessible_forward),
// color: Colors.white,
onPressed: () {
setState(() {
_index = 0;
});
}), IconButton(
icon: Icon(Icons.access_alarm),
// color:Colors.white,
onPressed: () {
setState(() {
_index = 1;
});
}),
IconButton(
icon: Icon(Icons.accessible_forward),
color: Colors.transparent,
onPressed: () {
setState(() {
_index = 2;
});
}),
IconButton(
icon: Icon(Icons.account_balance_wallet), // color:Colors.white,
onPressed: () {
setState(() {
_index = 3;
});
}),
IconButton(
icon: Icon(Icons.airport_shuttle),
// color:Colors.white,
onPressed: () {
setState(() {
_index = 4;
});
}),
],
),
),
);
}
}
import 'package:flutter/material.dart';

class EachView extends StatefulWidget {
String _title;
EachView(this._title);
@override
_EachViewState createState() => _EachViewState();
} class _EachViewState extends State<EachView> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar:AppBar(title:Text(widget._title)),
body: Center(child:Text(widget._title)),
);
}
}

效果:

最新文章

  1. H3 BPM让天下没有难用的流程之功能介绍
  2. .Net Core--目录
  3. iOS键盘输入屏幕上移
  4. 使用Angularjs的ng-cloak指令避免页面乱码
  5. MVC下判断PC和移动端
  6. $http服务和$location
  7. linux查看修改线程默认栈空间大小(ulimit -s)
  8. A New Tetris Game
  9. mysql 的数据文件
  10. ios专题 -内存管理 研究
  11. [转] JavaScript中的属性:如何遍历属性
  12. 不用标准库实现memmove,借助一个缓冲区temp,即使src和dest所指的内存有重叠也能正确拷贝
  13. 【Xamarin开发 Android 系列 8】 创建一个Json读取数据应用(上)
  14. fatal error C1083: Cannot open precompiled header file: &#39;Debug/xxoo.pch&#39;: No such file or directory
  15. SpringMVC, Spring和Mybatis整合案例一
  16. DotNetCore跨平台~在appsettings.json里自定义配置项
  17. Python3学习笔记33-正则表达式
  18. x64 assembler fun-facts(转载)
  19. Android电话拨打权限绕过漏洞(CVE-2013-6272)分析
  20. Android 各API版本代码常量

热门文章

  1. winform上传文件到服务器——资料整理
  2. python __main__ 里的变量是全局变量 因此在函数里面可以访问到
  3. pytest使用
  4. linux文档与目录结构
  5. Django之路——4 Django的视图层
  6. git常用命令总结--原创
  7. python关于字典嵌套字典,列表嵌套字典根据值进行排序
  8. netty: 将传递数据格式转为String,并使用分隔符发送多条数据
  9. ML,DL核心数学及算法知识点总结
  10. c# 隐藏窗口在ALT+TAB中