flutter - 刷新指示器不适用于 NestedScrollView
问题描述
@override
Widget build(BuildContext context) {
super.build(context);
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
),
child: Scaffold(
key: _scaffoldKeyProfilePage,
body: DefaultTabController(
length: 2,
child:RefreshIndicator(
onRefresh: _onRefresh,
child: NestedScrollView(
headerSliverBuilder: (context, _) {
return [
SliverList(
delegate: SliverChildListDelegate(
[ BuildMainProfile(
....//
),
Padding(
...//another design
),
];
},
// You tab view goes here
body: Column(
children: <Widget>[
TabBar(
tabs: [
Tab(text: 'A'),
Tab(text: 'B'),
],
),
Expanded(
child: TabBarView(
children: [
BuildPost(,
),
BuildWings()
],
),
),
],
),
),),
),
}
刷新指示器不适用于 NestedScrollView,有什么方法可以实现 RefreshIndictor?我尝试在堆栈中添加一个空的 ListView,刷新指示器开始显示,但因为我的 NestedScrollView 不滚动。
解决方案
您是否尝试将NestedScrollView
小部件设置physics
为AlwaysScrollableScrollPhysics()
?
请参阅RefreshIndicator的文档。
刷新指示器不显示
如果它的可滚动后代可以过度滚动,即如果可滚动的内容大于其视口,则 RefreshIndicator 将出现。为了确保 RefreshIndicator 始终出现,即使可滚动的内容适合其视口,请将可滚动的 Scrollable.physics 属性设置为 AlwaysScrollableScrollPhysics:
ListView( physics: const AlwaysScrollableScrollPhysics(), children: ... )
RefreshIndicator 只能用于垂直滚动视图。
推荐阅读
- reactjs - 如何在 typescript+webpack 项目中使用 js/jsx 文件?
- reactjs - 警告:上下文类型失败:上下文“可见”被标记为必需,但其值为“未定义”
- github - 我应该如何更正我的链接代码以便它可以在 Github 上运行?
- android-studio - 面临错误>>无法解决方法'with(匿名com.android.volley.Response.Listner
)' - python - Python中的索引错误
- python - 模板语言的 Django 不工作/呈现任何数据
- javascript - 使 ReactMarkdown 组件可编辑
- assembly - 为什么 GDB 检查结果会根据我是否事先检查字符串而有所不同?
- python - 我在 python 上安装 Pyaudio 时失败了
- python - Python AttributeError:“页面”对象没有属性“_getContents”