Closed
Description
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.
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)
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
iapicca commentedon 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
epoll-j commentedon Oct 21, 2019
Thank you for your answer @iapicca
but how to use SliverList with TabBarView
epoll-j commentedon Oct 21, 2019
Hi @iapicca
I try to use
SliverList
wrapped insideCustomScrollView
inTabBarView
, this problem still exists.wangfengnan commentedon Oct 25, 2019
same problem!
Tecode commentedon Jan 9, 2020
try NestedScrollView set physics ClampingScrollPhysics
NestedScrollView( physics: ClampingScrollPhysics(), body:Text(''), )
iapicca commentedon 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
xiechunyan commentedon Mar 27, 2020
There is still a problem on the iphone after adding physics. Is there a solution?
RockinPaul commentedon Mar 27, 2020
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 commentedon Mar 27, 2020
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?
VladyslavBondarenko commentedon May 6, 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
RockinPaul commentedon May 21, 2020
Hi @VladyslavBondarenko,
It seems to be fixed, I can't reproduce it as well.
VladyslavBondarenko commentedon May 21, 2020
oh, I accidentally tagged not the author)
Closing. If somebody still experiences the issue - feel free to comment or file a new issue
rafdls commentedon Jun 11, 2020
This problem still exists in the stable version though: Flutter v1.17.3
iapicca commentedon 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 commentedon Jul 29, 2020
nice , got it
lyz15 commentedon Aug 10, 2020
这个问题还没修复吗?可不可以贴一个终极解决方法的代码?
github-actions commentedon Aug 17, 2021
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.