1 Star 1 Fork 0

蔡江洋/flutter-custom-refresh-indicator

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
swipe_action.dart 2.85 KB
一键复制 编辑 原始数据 按行查看 历史
Kamil Klyta 提交于 3年前 . Release/v2.0.0 (#36)
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,
),
)
],
),
),
),
],
);
});
},
);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jiang-yang-cai/flutter-custom-refresh-indicator.git
git@gitee.com:jiang-yang-cai/flutter-custom-refresh-indicator.git
jiang-yang-cai
flutter-custom-refresh-indicator
flutter-custom-refresh-indicator
master

搜索帮助