Skip to content

NestedScrollView + ListView in iOS13 scroll bug #43086

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
epoll-j opened this issue Oct 20, 2019 · 17 comments
Closed

NestedScrollView + ListView in iOS13 scroll bug #43086

epoll-j opened this issue Oct 20, 2019 · 17 comments
Labels
e: OS-version specific Affects only some versions of the relevant operating system f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. platform-ios iOS applications specifically

Comments

@epoll-j
Copy link

epoll-j commented Oct 20, 2019

Hello guys,
I wrote a very basic page that has a NestedScrollView and a SliverAppBar and some listview wrapped inside tab.
Whenever I scrolling the page, it will often reset position to the top in iOS13, but it's normal in Android.

It look like this:
avatar

my code:

import 'package:flutter/material.dart';

class TestPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _TestPageState();

}

class _TestPageState extends State<TestPage> with TickerProviderStateMixin {
  ScrollController _scrollViewController =
  ScrollController(initialScrollOffset: 0.0);

  TabController _tabController;

  @override
  Widget build(BuildContext context) {
    _tabController = TabController(length: 4, vsync: this);
    return Scaffold(
      appBar: AppBar(
        title: const Text("title"),
      ),
      body: _buildBody(context),
    );
  }

  Widget _buildBody(BuildContext context) {
    List<String> _tabList = ["1", "2", "3", "4"];

    return NestedScrollView(
      controller: _scrollViewController,
      headerSliverBuilder: (BuildContext context, bool boxIsScrolled) {
        return <Widget>[
          SliverAppBar(
            pinned: true,
            floating: true,
            forceElevated: boxIsScrolled,
            backgroundColor: Colors.white,
            flexibleSpace: FlexibleSpaceBar(
              collapseMode: CollapseMode.pin,
              background: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Center(
                    child: Container(
                      height: 100,
                      width: 200,
                      color: Colors.blue,
                    ),
                  ),
                  Center(
                    child: Container(
                      height: 100,
                      width: 200,
                      color: Colors.red,
                    ),
                  ),
                  Center(
                    child: Container(
                      height: 100,
                      width: 200,
                      color: Colors.green,
                    ),
                  ),
                  Center(
                    child: Container(
                      height: 100,
                      width: 200,
                      color: Colors.yellow,
                    ),
                  )
                ],
              ),
            ),
            expandedHeight: 470,
            bottom: PreferredSize(
                child: TabBar(
                    controller: _tabController,
                    tabs: _tabList.map((item) {
                      return Tab(
                        child: Text(item, style: TextStyle(color: Colors.green),),
                      );
                    }).toList()),
                preferredSize: Size(double.infinity, 60)),
          )
        ];
      },
      body: TabBarView(
        controller: _tabController,
        children: _tabList.map((_) {
          return Center(
            child: ListView.builder(
              itemBuilder: (content, index) {
                return Center(
                  child: Text("$index"),
                );
              },
              itemCount: 100,
            ),
          );
        }).toList(),
      ),
    );
  }
}

fultter doctor:

[✓] Flutter (Channel stable, v1.9.1+hotfix.5, on Mac OS X 10.15 19A583, locale zh-Hans-CN)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 11.1)
[✓] Android Studio (version 3.4)
[!] IntelliJ IDEA Ultimate Edition (version 2019.1.4)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.39.2)
[✓] Connected device (1 available)
@janmoppel janmoppel added f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. platform-ios iOS applications specifically labels Oct 21, 2019
@iapicca
Copy link
Contributor

iapicca commented Oct 21, 2019

Hi @dubhe-jk
you might want to use a SliverList instead of a ListView.builder
Here's some documentation [1, 2]that can help your case

@iapicca iapicca added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Oct 21, 2019
@epoll-j
Copy link
Author

epoll-j commented Oct 21, 2019

Thank you for your answer @iapicca
but how to use SliverList with TabBarView

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Oct 21, 2019
@epoll-j
Copy link
Author

epoll-j commented Oct 21, 2019

Hi @iapicca
I try to useSliverList wrapped insideCustomScrollView inTabBarView , this problem still exists.

@wangfengnan
Copy link

same problem!

@Tecode
Copy link

Tecode commented Jan 9, 2020

try NestedScrollView set physics ClampingScrollPhysics
NestedScrollView( physics: ClampingScrollPhysics(), body:Text(''), )

@TahaTesser TahaTesser added the e: OS-version specific Affects only some versions of the relevant operating system label Mar 13, 2020
@iapicca
Copy link
Contributor

iapicca commented Mar 16, 2020

Hi all
if @Tecode solution
doesn't work for you and you are experiencing the issue
with the latest stable version of flutter
can you please provide your update flutter doctor -v ,
your flutter run --verbose
and a reproducible minimal code sample.
Thank you

@iapicca iapicca added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 16, 2020
@xiechunyan
Copy link

There is still a problem on the iphone after adding physics. Is there a solution?

@RockinPaul
Copy link

There is still a problem on the iphone after adding physics. Is there a solution?

Hello! Regarding @Tecode solution which doesn't work for me either - try to set ClampingScrollPhysics to a nested ListView, but not NestedScrollView itself. This is the only workaround I found for now.

@xiechunyan
Copy link

I've tried to do this before, but if you use it in the nested ListView, the iphone's sliding feature is gone.Is there any other solution?

@iapicca iapicca removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 27, 2020
@VladyslavBondarenko
Copy link

Hi @RockinPaul
Does the issue persist?
I can't reproduce it with iOS 13.4.5 on dev 1.18.0-10.0.pre

@VladyslavBondarenko VladyslavBondarenko added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 6, 2020
@RockinPaul
Copy link

Hi @VladyslavBondarenko,
It seems to be fixed, I can't reproduce it as well.

@VladyslavBondarenko
Copy link

oh, I accidentally tagged not the author)
Closing. If somebody still experiences the issue - feel free to comment or file a new issue

@VladyslavBondarenko VladyslavBondarenko removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 21, 2020
@rafdls
Copy link

rafdls commented Jun 11, 2020

Hi @RockinPaul
Does the issue persist?
I can't reproduce it with iOS 13.4.5 on dev 1.18.0-10.0.pre

This problem still exists in the stable version though: Flutter v1.17.3

@iapicca
Copy link
Contributor

iapicca commented Jul 20, 2020

Could everyone who still has this problem please file a new issue with the exact description of what happens, logs and the output of flutter doctor -v.
All system setups can be slightly different, so it's always better to open new issues and reference related issues.

@AcmeField
Copy link

添加物理后,iphone上仍然存在问题。有解决方案吗?

你好!关于对我也不起作用的@Tecode解决方案-尝试将ClampingScrollPhysics设置为嵌套的ListView,而不是NestedScrollView本身。这是我目前发现的唯一解决方法。

nice , got it

@lyz15
Copy link

lyz15 commented Aug 10, 2020

这个问题还没修复吗?可不可以贴一个终极解决方法的代码?

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
e: OS-version specific Affects only some versions of the relevant operating system f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. platform-ios iOS applications specifically
Projects
None yet
Development

No branches or pull requests