Skip to content

启动时刷新似乎有点问题,导致不会触发上拉加载 #787

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

Closed
xiaohucode opened this issue Dec 16, 2023 · 4 comments
Closed

Comments

@xiaohucode
Copy link

xiaohucode commented Dec 16, 2023

2023-12-16.17.29.08.mov

复现步骤:
首次进入会启动刷新
刷新完成不等待Header收起然后拖动到底部 不会触发上拉加载

使用版本:
easy_refresh: ^3.3.3+1

代码

import 'dart:async';

import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  List<int> list = [];
  int page = 1;
  final EasyRefreshController _controller =
      EasyRefreshController(controlFinishRefresh: true);

  @override
  void initState() {
    super.initState();
    // list = List.generate(10, (index) => index);
  }

  Future<IndicatorResult> getListData(int page) async {
    await Future.delayed(const Duration(seconds: 3));
    if (page == 1) {
      list = List.generate(20, (index) => index);
    } else {
      list.addAll(List.generate(20, (index) => index + list.length));
      page++;
    }

    setState(() {});

    return IndicatorResult.success;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: EasyRefresh(
        controller: _controller,
        onLoad: () async {
          return await getListData(page + 1);
        },
        onRefresh: () async {
          final res = await getListData(1);
          _controller.finishRefresh(res);
        },
        refreshOnStart: true,
        child: ListView.builder(
          itemCount: list.length,
          itemBuilder: (context, index) {
            return Container(
              decoration: BoxDecoration(
                border: Border.all(
                  width: 2.0,
                  color: Colors.red,
                ),
              ),
              height: 100,
              child: Text("index:$index"),
            );
          },
        ),
      ),
    );
  }
}


@xiaohucode
Copy link
Author

easy_refresh:
git:
url: https://github.com/xuelongqy/flutter_easy_refresh.git
ref: 3.3.2+1
使用这个版本没问题

@xuelongqy
Copy link
Owner

是的,最新版本修复了

@xiaohucode
Copy link
Author

是的,最新版本修复了

新版啥时候发呀?我用的是最新版3.3.3+1会出现这个问题

@xuelongqy xuelongqy reopened this Dec 21, 2023
xuelongqy added a commit that referenced this issue Dec 21, 2023
xuelongqy added a commit that referenced this issue Dec 29, 2023
@xuelongqy
Copy link
Owner

3.3.4已修复,如还有问题,请重新开启此issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants