本文介绍了滚动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可滚动
发布评论