当前位置:网站首页>flutter BottomNavigationBar切换页面保持状态
flutter BottomNavigationBar切换页面保持状态
2022-06-29 20:52:00 【海阔天空6688】
1、tabBar对应的每个页面实现AutomaticKeepAliveClientMixin,值改为true
2、tabBar对应的每个页面的build()方法调用super.build(context);
3、PageView中设置physics: const NeverScrollableScrollPhysics(), //禁止滑动
return Scaffold(
body: PageView.builder(
controller: _controller,
physics: const NeverScrollableScrollPhysics(), //禁止滑动
itemCount: list.length,
itemBuilder: (context, index) => list[index],
),
bottomNavigationBar: initBottomNavigationBar(),
);
///设置页面
class SettingPage extends StatefulWidget{
const SettingPage({Key? key}):super(key: key);
@override
State<SettingPage> createState() =>SettingState();
}
///实现AutomaticKeepAliveClientMixin
class SettingState extends State<SettingPage> with AutomaticKeepAliveClientMixin{
@override
Widget build(BuildContext context) {
super.build(context); //调用super.build(context);
return Scaffold(
appBar: AppBar(title: const Text("设置中心"),),
);
}
@override
bool get wantKeepAlive => true; //改为true
}
具体实现
边栏推荐
- AI scene Storage Optimization: yunzhisheng supercomputing platform storage practice based on juicefs
- Liunx instruction
- 【云原生实战】KubeSphere实战——多租户系统实战
- Navigation [microcomputer principle]
- At least 3 years for learning amplifier?
- Is it safe to open an account with flush for stock trading?
- Go deep into the underlying principles of go and rewrite redis middleware without secret
- Defense cornerstone in attack and defense drill -- all-round monitoring
- 社区访谈丨一个IT新人眼中的JumpServer开源堡垒机
- 期末复习【微机原理】
猜你喜欢

Comparable比较器写法&ClassCastExcption类转换异常

18. `bs object Node name next_ sibling` previous_ Sibling get sibling node

Bigder:自动化测试工程师

WIN10设置自动拨号联网任务,实现开机、断网自动重连

Cantata version 9.5 has officially passed the sgs-t Ü V certification and conforms to all major software safety standards

Fastadmin background setting radio button

智能门锁主流品牌有哪些?选购门锁时要注重产品的哪些特性?

计算成像前沿进展

leetcode:370. 区间加法

0/1分数规划专题
随机推荐
利用积分商城游戏进行营销需要避免哪些问题出现?
LSF bsub command
Application of VoIP push in overseas audio and video services
Go deep into the underlying principles of go and rewrite redis middleware without secret
如何评价科大讯飞AI翻译笔P20系列,值得买吗?
期末复习【微机原理】
"Xiaodeng" active directory batch user creation in operation and maintenance
60天远程办公经验分享 | 社区征文
导航 习题【微机原理】【习题】
. NETCORE unified authentication authorization learning - first authorization (2)
导航 实验【微机原理】【实验】
The reason why the log analysis tool of "operation and maintenance" is used more and more frequently
18. `bs object Node name next_ sibling` previous_ Sibling get sibling node
Jump to open a new window
Coreldraw2022 new version v24.1.0.360 update
Analysis on the true topic of "cost management" by Guangdong second-class cost engineer
Mapbox GL development tutorial (12): loading surface layer data
At least 3 years for learning amplifier?
How to evaluate iFLYTEK AI translation pen P20 series? Is it worth buying?
leetcode:238. 除自身以外数组的乘积