flutter - 如何在页面向上滚动时隐藏底部导航栏?
问题描述
我已经创建了一个NavigationBar
像下面这样的底部,但是当页面向上滚动时我很难隐藏它,如果页面向下滚动则再次显示它。
我在正文和底部导航栏中有一个博客文章列表。我想在帖子列表向上滚动时隐藏底部导航栏,并通过向下滑动动画使其可见。这个怎么做?
向上滚动时隐藏 BottomNavigationBar。这是我的 BottomNavigationBar 代码:
class _HomePageState extends State<HomePage> {
bool isSignedIn= false;
int _CurrentIndex=0;
int _agentCurrentIndex=0;
String owneruerID;
String uploadusertypes;
List<Widget>_children;
List<Widget>_agentchildren;
void initState(){
super.initState();
GetData();
uploadusertypes= widget.UserType;
owneruerID = widget.userID;
_children=[
TimeLinePage(tuserID:owneruerID,tUserType:uploadusertypes),
ManinClass(), //search(),
UploadPage(UserSID:owneruerID,uploadusertypes:uploadusertypes),
NotificationsPage(),
ProfilePage(userProfileID:owneruerID),
];
if(FirebaseAuth.instance.currentUser!=null){
setState(() {
isSignedIn= true;
});
}else{
setState(() {
isSignedIn= false;
});
}
}
----------
@override
Widget build(BuildContext context) {
if (isSignedIn) {
return buildagentScreen();
}else
{
return buildHomeScreen();
}
}
----------
Scaffold buildHomeScreen(){
return Scaffold(
backgroundColor: Colors.black,
body: _children[_CurrentIndex],
bottomNavigationBar: CupertinoTabBar(
currentIndex: _CurrentIndex,
backgroundColor: Colors.black,
onTap: onTabchangePage,
activeColor: Colors.green,
inactiveColor: Colors.white,
items: [
BottomNavigationBarItem(icon:Icon(Icons.home),title: Text('home'),),
BottomNavigationBarItem(icon:Icon(Icons.search)),
BottomNavigationBarItem(icon:Icon(Icons.photo_camera,size: 40,)),
BottomNavigationBarItem(icon:Icon(Icons.notifications)),
BottomNavigationBarItem(icon:Icon(Icons.person_add_alt_1_sharp)),
],
),
);
}
解决方案
推荐阅读
- javascript - 在不丢失原始堆栈的情况下覆盖 console.log 方法 - javascript
- struct - LLVM 后端如何处理具有动态访问权限的结构的 getelementptr?
- cryptography - 无法将 pkcs11-tool 与自定义 hsm 角色一起使用
- automation - 我正在尝试使用 7-zip 和 AutoHotKey 提取文件夹,但脚本仅在新窗口中打开压缩文件夹
- drools - 如何使用 Drools Api 声明窗口
- python - 如何更改 django 选择字段的呈现属性?
- arrays - 使用数据表访问多维数组上的对象
- module - Yocto 上的 v4l2loopback
- python - AWS CDK 创建 aws_codestarnotifications.CfnNotificationRule 并设置目标
- pine-script - 仅当信号在 TSI 指标中穿过中线时才使用 plotchar