peng8350 / flutter_pulltorefresh

a widget provided to the flutter scroll component drop-down refresh and pull up load.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

使用SmartRefresher列表显示被拉伸

bianweiall opened this issue · comments

import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import './controller.dart';
import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart';

class CreativeCenterPage2 extends GetView<CreativeCenterController> {
  const CreativeCenterPage2({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: MediaQuery.removePadding(
          context: context,
          removeTop: true,
          removeBottom: false,
          child: Obx(
            () => Scrollbar(
                controller: controller.scrollController,
                child: SmartRefresher(
                  enablePullDown: true,
                  enablePullUp: true,
                  header: const WaterDropHeader(
                    complete: Text("刷新完成"),
                  ),
                  footer: CustomFooter(
                    builder: (BuildContext context, LoadStatus? mode) {
                      final Widget body;
                      switch (mode) {
                        case LoadStatus.idle:
                          body = const Text("上拉加载");
                          break;
                        case LoadStatus.loading:
                          body = const CupertinoActivityIndicator();
                          break;
                        case LoadStatus.failed:
                          body = const Text("加载失败!点击重试!");
                          break;
                        case LoadStatus.canLoading:
                          body = const Text("加载更多!");
                          break;
                        default:
                          body = const Text("没有更多数据了!");
                      }

                      return SizedBox(
                        height: 50,
                        child: Center(child: body),
                      );
                    },
                  ),
                  controller: controller.refreshController,
                  onRefresh: controller.onRefresh,
                  onLoading: controller.onLoading,
                  child: ListView.builder(
                    itemBuilder: (context, index) {
                      var object = controller.items[index];
                      return Container(
                        constraints: const BoxConstraints(maxWidth: 800),
                        margin: const EdgeInsets.only(left: 10, right: 10),
                        padding: const EdgeInsets.only(top: 10, bottom: 10),
                        decoration: BoxDecoration(
                          border: Border(
                            bottom: BorderSide(
                              width: 1,
                              color: Colors.grey[100]!,
                            ),
                          ),
                        ),
                        child: Center(child: Text(object.name)),
                      );
                    },
                    padding: const EdgeInsets.all(1.0),
                    controller: controller.scrollController,
                    itemCount: controller.items.length,
                    physics: const AlwaysScrollableScrollPhysics(),
                  ),
                )),
          )),
      floatingActionButton: FloatingActionButton(
        onPressed: controller.onAdd,
        child: const Icon(Icons.add),
      ),
    );
  }
}

拉伸后:
1

正常:
2

same problem in Android device

same error。But you can use physics: const BouncingScrollPhysics() temporary endings `SmartRefresher(

      physics: const BouncingScrollPhysics(),...`,Looks like AlwaysScrollableScrollPhysics () mapping and SmartRefresher incompatible。

`SmartRefresher(

  physics: const BouncingScrollPhysics(),...`

Or you can leave pull_to_refresh3 out and use pull_to_refresh^2.0.0 instead