Skip to content
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

数据超过一屏不能下拉刷新 #645

Open
xaiocaiji7653 opened this issue Apr 18, 2024 · 1 comment
Open

数据超过一屏不能下拉刷新 #645

xaiocaiji7653 opened this issue Apr 18, 2024 · 1 comment

Comments

@xaiocaiji7653
Copy link

Widget build(BuildContext context) {
return SmartRefresher(
enablePullDown: true,
enablePullUp: true,
controller: _refreshController,
onRefresh: () {
_feedController.refreshHotFeedList(_refreshController);
},
onLoading: () {
_feedController.getHotFeedList(_refreshController);
},

 child: _getInvitationList(context));

}

_getInvitationList(BuildContext context) {
return Obx(() {
List invitationList = _feedController.hotFeedList;
if (invitationList.isEmpty) {
return Container(
color: ColorRes.color_14,
height: MediaQuery.of(context).size.height,
);
} else {
return ListView.separated(
separatorBuilder: (context, index) => const Divider(
// height: 10,
thickness: 5,
color: ColorRes.color_14,
),
controller: _pageController,
itemCount: invitationList.length,
itemBuilder: (context, index) {
return Container(
height: 80,
child: Text("$index"),
);

为什么当数据不满一屏的时候可以下拉和上拉,满了就不能下拉和上拉刷新了啊

@anjarnaufals
Copy link

Hello @xaiocaiji7653
maybe you can try this bro, hope this can help

class Example extends StatefulWidget {
  const Example({super.key});

  @override
  State<Example> createState() =>
      _ExampleState();
}

class _ExampleState
    extends State<Example> {
  final RefreshController _refreshController = RefreshController();

  Future<void> testRefresh() async {
    _refreshController.requestRefresh();
    await Future.delayed(Durations.extralong4);
    _refreshController.refreshCompleted();
  }

  Future<void> testLoadMore() async {
    _refreshController.requestLoading();
    await Future.delayed(Durations.extralong4);
    _refreshController.loadComplete();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Data Not Exceed Screen'),
      ),
      body: SmartRefresher(
        onRefresh: () async {
          testRefresh();
        },
        onLoading: () {
          testLoadMore();
        },
        controller: _refreshController,
        enablePullDown: true,
        enablePullUp: true,
        header: const ClassicHeader(),
        child: ListView.builder(
          itemCount: 1,
          itemBuilder: (_, __) => const Text('Only this Data'),
        ),
      ),
    );
  }
}

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