flutter 下拉刷新插件flutter_easyrefresh

效果图如下 插件地址

flutter 下拉刷新插件flutter_easyrefresh_第1张图片

1 . 配置文件 pubspec.yaml

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
   ...
  flutter_easyrefresh: ^2.1.

**2 . 配置文件main.dart **

...
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
	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-

如:

flutter 下拉刷新插件flutter_easyrefresh_第2张图片
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
flutter 下拉刷新插件flutter_easyrefresh_第3张图片

你可能感兴趣的:(Flutter)