gpt4 book ai didi

flutter - 没有 ScrollView 的刷新指示器

转载 作者:IT老高 更新时间:2023-10-28 12:30:04 26 4
gpt4 key购买 nike

我知道 ListViewSingleChildScrollView RefreshIndicator 只能在本地工作,但我想使用 RefreshIndicator不滚动的页面。这甚至可能吗?如果可以,怎么做?

最佳答案

您必须执行以下操作:

  • 使用 SingleChildScrollView 并将属性 physics 设置为 AlwaysScrollableScrollPhysics()
  • 确保它的 child 具有屏幕大小的高度,您可以通过 MediaQuery.of(context).size.height 获得。

完整的例子:

classs MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return RefreshIndicator(
onRefresh: () {},
child: SingleChildScrollView(
physics: AlwaysScrollableScrollPhysics(),
child: Container(
child: Center(
child: Text('Hello World'),
),
height: MediaQuery.of(context).size.height,
),
),
);
}
}

关于flutter - 没有 ScrollView 的刷新指示器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50195259/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com