This commit is contained in:
Patrick Alvin Alcala 2025-02-26 15:23:42 +08:00
parent 06b853b2ca
commit 9d5a392db3
9 changed files with 206 additions and 156 deletions

View file

@ -0,0 +1,35 @@
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class PullRefreshWidget extends StatefulWidget {
final Widget child;
const PullRefreshWidget({super.key, required this.child});
@override
State<PullRefreshWidget> createState() => _PullRefreshWidgetState();
}
class _PullRefreshWidgetState extends State<PullRefreshWidget> {
final RefreshController refreshController = RefreshController(initialRefresh: false);
void onRefresh() async {
await Future.delayed(Duration(milliseconds: 1000));
refreshController.refreshCompleted();
}
void onLoading() async {
await Future.delayed(Duration(milliseconds: 1000));
if (mounted) setState(() {});
refreshController.loadComplete();
}
@override
Widget build(BuildContext context) {
return SmartRefresher(
controller: refreshController,
enablePullDown: true,
onRefresh: onRefresh,
onLoading: onLoading,
child: widget.child);
}
}