问题描述
我实际上是在尝试实现与 whatsapp for android 中相同的效果,即应用栏在向下滚动时消失并在向上滚动时重新出现的方式 这是我试过的,但我没有得到我想要的效果,appbar 没有立即出现或消失,它一直等到我把手离开屏幕
ScrollController scrollController;
TabController tabController;
TextStyles textStyles = TextStyles();
@override
void initState() {
super.initState();
tabController = TabController(length: 5,vsync: this);
scrollController = ScrollController();
}
@override
void dispose() {
// Todo: implement dispose
super.dispose();
tabController.dispose();
scrollController.dispose();
}
@override
Widget build(BuildContext context) {
final colors = AppColors();
final actionIcon = Icon(
Icons.search,color: Colors.white,);
final Function onpressed = () {};
return Scaffold(
body: nestedScrollView(
floatHeaderSlivers: true,controller: scrollController,headerSliverBuilder: (_,innerBoxIsScrolled) => [
buildSliverAppBar(innerBoxIsScrolled,colors,actionIcon,onpressed)
],body: buildTabBarView(),),);
}
//build tabbar
TabBarView buildTabBarView() {
return TabBarView(controller: tabController,children: [
HoMetabPage(
tabTitle: 'Featured',HoMetabPage(tabTitle: 'Online Now'),HoMetabPage(tabTitle: 'New to jiko'),HoMetabPage(tabTitle: 'discounts'),Categories()
]);
}
//build the appbar (containing the logo and the search)
SliverAppBar buildSliverAppBar(bool innerBoxIsScrolled,AppColors colors,Icon actionIcon,Function onpressed) {
return SliverAppBar(
title: Padding(
padding: const EdgeInsets.only(top: 16),child: Text('logo'),elevation: 0,snap: true,floating: true,pinned: true,bottom: PreferredSize(
preferredSize: Size.fromHeight(50),child: Align(
alignment: AlignmentDirectional.centerStart,child: Padding(
padding: const EdgeInsets.only(left: 8),child: TabBar(
unselectedLabelColor: colors.greyText,labelPadding: EdgeInsets.symmetric(horizontal: 8),indicatorSize: TabBarIndicatorSize.label,isScrollable: true,controller: tabController,labelStyle: textStyles.subtitle2,tabs: [
Tab(
text: 'Featured',Tab(
text: 'Online Now',Tab(
text: 'New to jiko',Tab(
text: 'discounts',Tab(
text: 'Categories',]),actions: [
ActionButton(colors: colors,icon: actionIcon,onpressed: onpressed)
],);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)