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

Not works well with NestedScrollView #758

Open
webMing opened this issue Sep 4, 2023 · 2 comments
Open

Not works well with NestedScrollView #758

webMing opened this issue Sep 4, 2023 · 2 comments

Comments

@webMing
Copy link

webMing commented Sep 4, 2023

@override
  Widget build(BuildContext context) {
    return DefaultTabController(
        length: tabs.length, //
        child: Scaffold(
            body: NestedScrollView(
          headerSliverBuilder: (context, innerBoxIsScrolled) {
            return [
              const SliverAppBar(
                centerTitle: true,
                title: Text('XXXX'),
                pinned: true,
                forceElevated: false,
              ),
               SliverToBoxAdapter(
               // child: HomeHeader(),
               child: Container(color: Colors.red,height: 300,width: double.infinity,),
              ),
              SliverOverlapAbsorber(
                handle:
                    NestedScrollView.sliverOverlapAbsorberHandleFor(context),
                sliver: SliverPersistentHeader(
                    pinned: true,
                    delegate: _MyDelegate(
                      height: 44,
                      child: TabBar(
                        indicatorSize: TabBarIndicatorSize.label,
                        tabs:
                            tabs.map((String name) => Tab(text: name)).toList(),
                      ),
                    )),
              ),
            ];
          },
          body: TabBarView(
            children: tabs.map((String name) {
              return SafeArea(
                top: false,
                child: Builder(
                  builder: (BuildContext context) {
                    return EasyRefresh(
                      child: CustomScrollView(
                        key: PageStorageKey<String>(name),
                        slivers: <Widget>[
                          SliverOverlapInjector(
                            handle:
                                NestedScrollView.sliverOverlapAbsorberHandleFor(
                                    context),
                          ),
                          SliverList.builder(
                            itemBuilder: (context, index) {
                              return const Text('adfkfdj');
                            },
                          )
                        ],
                      ),
                      onRefresh: () async {
                        Future.delayed(const Duration(seconds: 1));
                      },
                    );
                  },
                ),
              );
            }).toList(),
          ),
        )));
  }
}

cn:这里的下拉刷新是有问题的,有什么方法可以解决吗? 不想用官方提供的 nested scoll 的 demo 这样开发者会有更多的自由度,
en:There is a problem with pull-down refresh here, is there any way to fix it? Do not want to use the official nested scoll demo, so that developers will have more freedom

@xuelongqy
Copy link
Owner

NestedScrollView很多问题在下拉刷新中无解。非必要不建议使用NestedScrollView

@webMing
Copy link
Author

webMing commented Sep 5, 2023

NestedScrollView很多问题在下拉刷新中无解。非必要不建议使用NestedScrollView

感觉出现这个问题和处理sliverOverlapAbsorber有关,但换成官方提供的 RefreshIndicator 是没有问题, 看了一下RefreshIndicator实现中也没有特殊处理通过特殊方式来处理类似sliverOverlapAbsorber的情况,也没有思路了

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