-
-
Notifications
You must be signed in to change notification settings - Fork 643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v3的easy refresh在使用Cupertino样式时,初始化刷新失效 #586
Comments
不清楚你的具体问题是什么,也许参考示例可以帮助你,并找到问题 |
就是在使用Cupertino样式https://docs.flutter.dev/development/ui/widgets/cupertino下使用EasyRefresh并开启 |
我测试没有问题嘞,能给一个简单的示例吗? |
请参考这个 import 'dart:io';
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return const CupertinoApp(
title: 'Flutter Demo',
theme: CupertinoThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
//primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
EasyRefreshController _controller = EasyRefreshController(controlFinishRefresh: true, controlFinishLoad: true);
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: const Text("DEMO"),
),
child: EasyRefresh(
header: ClassicHeader(),
footer: ClassicFooter(),
refreshOnStart: true,
controller: _controller,
onLoad: () async{
//sleep(Duration(seconds: 5));
setState((){
_counter += 10;
});
_controller.finishLoad(IndicatorResult.success);
return IndicatorResult.success;
},
onRefresh: () async{
//sleep(Duration(seconds: 5));
setState((){
_counter = 10;
});
_controller.finishRefresh(IndicatorResult.success);
return IndicatorResult.success;
},
child: ListView.builder(
itemBuilder: (context, index) {
return Card(
child: Text((index + 1).toString()),
);
},
itemCount: _counter,
),
),
// This trailing comma makes auto-formatting nicer for build methods.
);
}
}
|
我看了示例代码。这是安全区域的问题,在EasyRefresh外层加一个SafeArea即可。不过首次刷新确实有点问题,没有计算出正确的安全区域偏移量,这个会在下个版本修复 |
感谢,那我等修复吧,我懒得改了,感谢作者 |
3.0.4+2应该可以了,不过还是建议你加上SafeArea |
好滴,感谢,我去更新一下 |
RT,当我的界面使用了Cupertino的时候,无法初始化刷新,并且有一个很奇怪的placeholder,如下图所示
当然也可以手动下滑刷新出页面,但是每个页面都需要手动下拉刷新,就很麻烦。
但是使用material界面的时候,初始化刷新又是正常的:
这个很迷惑,我也不知道是什么原因。
The text was updated successfully, but these errors were encountered: