代码拉取完成,页面将自动刷新
import 'package:custom_refresh_indicator/custom_refresh_indicator.dart';
import 'package:example/widgets/example_app_bar.dart';
import 'package:flutter/material.dart';
class FetchMoreIndicator extends StatelessWidget {
final Widget child;
final VoidCallback onAction;
const FetchMoreIndicator({
Key? key,
required this.child,
required this.onAction,
}) : super(key: key);
@override
Widget build(BuildContext context) {
const height = 150.0;
return CustomRefreshIndicator(
onRefresh: () async => onAction(),
trigger: IndicatorTrigger.trailingEdge,
trailingScrollIndicatorVisible: false,
leadingScrollIndicatorVisible: true,
child: child,
builder: (
BuildContext context,
Widget child,
IndicatorController controller,
) {
return AnimatedBuilder(
animation: controller,
builder: (context, _) {
final dy = controller.value.clamp(0.0, 1.25) *
-(height - (height * 0.25));
return Stack(
children: [
Transform.translate(
offset: Offset(0.0, dy),
child: child,
),
Positioned(
bottom: -height,
left: 0,
right: 0,
height: height,
child: Container(
transform: Matrix4.translationValues(0.0, dy, 0.0),
padding: const EdgeInsets.only(top: 30.0),
constraints: const BoxConstraints.expand(),
child: Column(
children: [
if (controller.isLoading)
Container(
margin: const EdgeInsets.only(bottom: 8.0),
width: 16,
height: 16,
child: const CircularProgressIndicator(
color: appContentColor,
strokeWidth: 2,
),
)
else
const Icon(
Icons.keyboard_arrow_up,
color: appContentColor,
),
Text(
controller.isLoading
? "Fetching..."
: "Pull to fetch more",
style: const TextStyle(
color: appContentColor,
),
)
],
),
),
),
],
);
});
},
);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。