效果圖如下
1 . 配置文件 pubspec.yaml
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
...
flutter_easyrefresh: ^2.1.1
**2 . 配置文件main.dart **
...
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
localizationsDelegates: [
GlobalEasyRefreshLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate
],
//國際化
supportedLocales: [
Locale('zh', 'CN'),
],
4. 組件頁面頁面上使用:
EasyRefresh(
header: PhoenixHeader(), //頭部刷新
footer: TaurusFooter(), //底部刷新
onRefresh: () async{
//下拉請求新數據
},
onLoad: () async {
//下拉增加新數據
},
//需要上下拉刷新的組件 這裏是CustomScrollView
child: CustomScrollView(...)
)
各種刷新樣式可以點這裏:
https://pub.flutter-io.cn/packages/flutter_easyrefresh#-readme-tab-
如: