使用组件:bottomNavigationBar
再tabs切换页面引入要被切换的组件内容(页面上显示的内容)
这里准备了三个
import './page/tabs/hoeme.dart';
import './page/tabs/setinde.dart';
import './page/tabs/category.dart';
准备一个组件用在tabs切换
核心代码
Scaffold(
appBar: AppBar(
title: Text("data"),
),
body: listpage[this._currentIndex],
bottomNavigationBar: BottomNavigationBar(
currentIndex: this._currentIndex,
onTap: (int inxdex) {
setState(() {
this._currentIndex = inxdex;
print(this._currentIndex);
});
},
items: [
BottomNavigationBarItem(
icon: Icon(Icons.message),
title: Text('消息'),
),
BottomNavigationBarItem(
icon: Icon(Icons.chat),
title: Text('消息'),
),
BottomNavigationBarItem(
icon: Icon(Icons.contacts),
title: Text('联系'),
),
]),
);
需要注意你的——你的tabs 跟页面数需要对应,并且当你的tbs按钮大于了3个时候 一定设置
type: BottomNavigationBarType.fixed,
否则无法正常显示