当前位置:网站首页>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
}
具体实现
边栏推荐
- .NetCore统一认证授权学习——Run(1)
- Cmake开发-多目录工程
- "Operation and maintenance department has Xiao Deng" to review and analyze file and folder access rights
- [buuctf.reverse] 142_ [SUCTF2019]babyunic
- Three.js开发:粗线的画法
- Is it safe to open an account with flush for stock trading?
- Cmake development - Multi Directory Project
- A Japanese Cherry sold at a sky high price of 1980 yuan. Netizen: I feel cheated after eating it
- 注解
- Calibration, correction and world coordinate calculation of binocular stereo vision camera (openCV)
猜你喜欢
「运维有小邓」日志分析工具使用越来越频繁的原因
期末复习【微机原理】
习近平在湖北武汉考察时强调 把科技的命脉牢牢掌握在自己手中 不断提升我国发展独立性自主性安全性
Clock tree synthesis (CTS)
Storage principle of string
leetcode:307. 区域和检索 - 数组可修改
AI scene Storage Optimization: yunzhisheng supercomputing platform storage practice based on juicefs
Sentinel's quick start takes you through flow control in three minutes
Chainsafe cross chain bridge deployment tutorial
LSF-bsub命令
随机推荐
fastadmin后台设置单选按钮
【云原生实战】KubeSphere实战——多租户系统实战
go: 如何编写一个正确的udp服务端
[buuctf.reverse] 142_ [SUCTF2019]babyunic
WIN10设置自动拨号联网任务,实现开机、断网自动重连
注解
Analysis on the true topic of "cost management" by Guangdong second-class cost engineer
「运维有小邓」AD域委派
Initialization of global and static variables
Three. JS development: drawing of thick lines
Liunx instruction
[compilation principle] type check
Flume ng configuration
Analysis of the factors affecting the transmission signal of the conductive slip ring
Codeforces Global Round 21 C D E
双目立体视觉摄像头的标定、矫正、世界坐标计算(opencv)
Deploy web using gunicorn Py application
Reinforcement learning weekly (issue 51): integration of PAC, ilql, RRL & model free reinforcement learning into micro grid control: overview and Enlightenment
导航 习题【微机原理】【习题】
I found another cross domain method by chance. I don't know if anyone has ever played this way