滚动TabBarView子级时,使SliverAppBar可滚动

编程入门 行业动态 更新时间:2024-10-10 07:29:21
本文介绍了滚动TabBarView子级时,使SliverAppBar可滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个带有底部导航的主屏幕,该项目由两个项目组成,它们都具有无限列表内的ListView,并且我希望SliverAppBar在用户滚动其中一个列表时可滚动. 这是我到目前为止所拥有的

I have home screen with bottom navigation consist of two items which all have ListView inside with infinite list and I want SliverAppBar to be scrollable when user scrolls in one of the list. Here is what I have so far

class HomeScreen extends StatelessWidget { @override Widget build(BuildContext context) { return DefaultTabController( length: 2, child: new Scaffold( body: CustomScrollView( slivers: <Widget>[ SliverAppBar( snap: false, floating: false, pinned: true, expandedHeight: 160.0, flexibleSpace: FlexibleSpaceBar( title: Text('Title'), ), ), SliverFillRemaining( child: TabBarView( children: <Widget>[Items(), Activities()], //THESE HAVE LIST VIEW IN EACH ), ) ], ), )); } }

这是TabBarView子级之一的代码.

And here is code of one of TabBarView children.

class Items extends StatelessWidget { @override Widget build(BuildContext context) { List<Widget> itemsWidgets = List.from(getItemsList() .map((Item item) => createItemWidget(context, item))); return Scaffold( body: Center( child: ListView( children: itemsWidgets, ), ), ); } ListTile createItemWidget(BuildContext context, Item item) { return new ListTile( title: Text(item.sender.name), subtitle: Text('10:30 am'), ); } }

当用户滚动列表之一时,SilverAppBar如何滚动?任何帮助/建议将不胜感激.

How can SilverAppBar be scrollable when user scrolls in one of the list? Any help/suggestion will be appreciated.

推荐答案

使用 NestedScrollView . api中有一个示例

Use NestedScrollView. There is an example in the api

更多推荐

滚动TabBarView子级时,使SliverAppBar可滚动

本文发布于:2023-11-23 04:21:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620067.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:TabBarView   子级时   SliverAppBar

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!