我有两个ListViews,第一个是页面的顶部,显示故事,所以是horizontal,第二个是显示帖子,所以是vertical。
我想要的是,当我scroll我的帖子,我希望故事消失,现在,他们被困在页面上。
解说视频 这
@override
Widget build(context) {
return Scaffold(
body: SafeArea(
child: Column(
children: [
Container(
padding: EdgeInsets.only(left: 15),
height: 90,
width: double.infinity,
child: StreamBuilder(
stream: masterListStart().asStream(),
builder: (context, snapshot) {
return (ConnectionState.done == snapshot.connectionState)
//First Listview
? ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: storysList.length,
itemBuilder: (context, index) {
//
StoryItems data = storysList[index];
//
return StoryItems(
data: data,
);
},
)
: CircularProgressIndicator();
}
},
),
);
//Second ListView
Expanded(
child: RefreshIndicator(
child: ListView(
children: posts,
),
key: refreshkey,
onRefresh: () => refreshlist(),
);
),
],
),
),
);
}发布于 2021-02-16 11:32:25
您可以像这样使用CustomScrollView。
CustomScrollView(
slivers : [
SliverToBoxAdapter(child : Container(height : listHeight,
child ListView(),),),
SliverList(delegate: SliverChildBuilderDelegate((context,index){
return Your Item;
},
childCount: data.length
),]发布于 2021-02-16 11:10:32
您可以将您的故事列表视图放在SliverAppBar中,当您向上滚动时,它将隐藏您的故事列表。这是链接https://flutter.dev/docs/cookbook/lists/floating-app-bar
发布于 2021-02-16 11:36:30
您可以在SingleChildScrollView的基础上添加Column来加载整个属性。
然后,您可以用这个code在第二个中停止scroll。
ListView(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true, // Edit new line
.
.
),在本例中,您将有一个SingleChildScrollView后面的vertical scroll,页面是完全动画的。
https://stackoverflow.com/questions/66223162
复制相似问题