简体   繁体   English

Flutter在CustomScrollView中使用RefreshIndicator

[英]Flutter use RefreshIndicator in CustomScrollView

I'm working with Flutter v0.5.1 我正在使用Flutter v0.5.1

I want to build a app with SliverAppBar to auto hide when scroll up and float when scroll down. 我想用SliverAppBar构建一个应用程序,以便在向上滚动时自动隐藏,在向下滚动时浮动。 I use CustomScrollView with sliverList are SliverAppBar and MyWidget1, which is a FutureBuilder to show CircularProgressIndicator when loading data and MyWidget2 when successfully loaded data. 我将sliverList与CustomScrollView一起使用的是SliverAppBar和MyWidget1,后者是FutureBuilder,用于在加载数据时显示CircularProgressIndicator,而在成功加载数据时显示MyWidget2。 MyWidget2 is a RefreshIndicator to user can pull to refresh data. MyWidget2是一个RefreshIndicator,用户可以拉动刷新数据。 The layout I expect is CustomScrollView -> (SliverAppBar and FutureBuilder -> RefreshIndicator) 我期望的布局是CustomScrollView->(SliverAppBar和FutureBuilder-> RefreshIndicator)

And the problem is that I can't use RefreshIndicator in CustomScrollView because CustomScrollView need a SliverList with RenderSliver and RefreshIndicator is not. 问题是我不能在CustomScrollView中使用RefreshIndicator,因为CustomScrollView需要带有RenderSliv​​er的SliverList,而RefreshIndicator却不是。

After trying more times I find out RefreshIndicator must be inside FutureBuilder because if reverse the order RefreshIndicator would rebuild FutureBuilder and show CircularProgressIndicator when it refresh. 尝试了更多次后,我发现RefreshIndicator必须在FutureBuilder内,因为如果反向执行,则RefreshIndicator会重建FutureBuilder并在刷新时显示CircularProgressIndicator。 I expect to show only RefreshIndicator. 我希望仅显示RefreshIndicator。 And I want to use FutureBuilder inside CustomScrollView to show SliverAppBar when FutureBuilder show CircularProgressIndicator 我想在FutureScroller显示CircularProgressIndicator时在CustomScrollView中使用FutureBuilder显示SliverAppBar

Any idea for me 对我有什么想法

Thank all, 谢谢大家


p/s: sr for my English ps:我的英语是sr

Just make sure, did you try like this? 只要确定,您是否尝试过这种方法? RefreshIndicator -> CustomScrollView -> other silvers. RefreshIndicator-> CustomScrollView->其他银色。 It works, but you don't want to do like this, right? 它有效,但是您不想这样做,对吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM