Repository navigation
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.Affects or could affect many people, though not necessarily a specific customer.f: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7Found to occur in 3.7frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: duplicateIssue is closed as a duplicate of an existing issueIssue is closed as a duplicate of an existing issue
Description
Steps to Reproduce
- Change tab to Tab 2
- Scroll inner list in Tab 2
- Change tab to Tab 1
- Inner list in Tab 1 has also scrolled
If we switch tabs, States outside the screen will be disposed.
In many cases, loading data is a heavy process, so I want to keep States.
I am going to use AutomaticKeepAliveClientMixin for that.
However, with this combination of Widgets,
the scroll operation also affects the scroll view of other tabs.
- Without NestedScrollView, this does not occur
- Without AutomaticKeepAliveClientMixin, this does not occur
- When wantKeepAlive is false, this does not occur
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(home: MyApp()));
const _kTabs = ["Tab 1", "Tab 2"];
class MyApp extends StatefulWidget {
MyAppState createState() => MyAppState();
}
class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
ScrollController scrollController = ScrollController();
@override
Widget build(BuildContext context) {
final Widget tabBar = TabBar(
tabs: _kTabs.map<Widget>((String name) => Tab(text: name)).toList());
return Scaffold(
body: DefaultTabController(
length: _kTabs.length,
child: NestedScrollView(
controller: scrollController,
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
title: Text("Title"),
bottom: tabBar,
pinned: true,
forceElevated: innerBoxIsScrolled,
),
];
},
body: TabBarView(
children: _kTabs.map((String name) {
return Container(
key: PageStorageKey(name),
child: MyListView(),
);
}).toList(),
),
),
),
);
}
}
class MyListView extends StatefulWidget {
@override
_MyListViewState createState() => _MyListViewState();
}
class _MyListViewState extends State<MyListView> with AutomaticKeepAliveClientMixin {
@override
final bool wantKeepAlive = true;
@override
Widget build(BuildContext context) {
super.build(context);
return ListView.builder(
itemBuilder: (BuildContext context, int index) {
return ListTile(
title: Text('Item $index'),
);
},
);
}
}Logs
[✓] Flutter (Channel v1.7.8-hotfixes, v1.7.8+hotfix.3, on Mac OS X 10.14.4 18E226, locale ja-JP)
• Flutter version 1.7.8+hotfix.3 at /Applications/flutter
• Framework revision b712a172f9 (8 days ago), 2019-07-09 13:14:38 -0700
• Engine revision 54ad777fd2
• Dart version 2.4.0
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/najeira/Library/Android/sdk
• Android NDK at /Users/najeira/Library/Android/sdk/ndk-bundle
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /Users/najeira/Library/Android/sdk
• ANDROID_SDK_ROOT = /Users/najeira/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 10.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2, Build version 10E125
• CocoaPods version 1.7.4
[✓] iOS tools - develop for iOS devices
• ios-deploy 1.9.4
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 34.0.1
• Dart plugin version 182.5215
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[✓] IntelliJ IDEA Ultimate Edition (version 2018.1)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 31.1.1
• Dart plugin version 181.4203.498
[✓] VS Code (version 1.35.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.0.2
[✓] Connected device (5 available)
• SC 02H • 145faa87 • android-arm64 • Android 8.0.0 (API 26)
• HW 01K • LPF0218529000628 • android-arm64 • Android 8.1.0 (API 27)
• TetsuhiroのiPod touch • 8669364bb2135049086983a6bcc1f2db7cdd255e • ios • iOS 12.3.1
• macOS • macOS • darwin-x64 • Mac OS X 10.14.4 18E226
• web • web • web-javascript • Google Chrome 75.0.3770.142
Reacted by Jpeng, Jasper van Riet, ysknsn, Lucas de Ávila Martins, Yong, Arcrueid, John, luckysmg, Maryan, Henrique Arthur and 49 more
Reacted by Phạm Quốc Trọng and chenyang
Reacted by Marcello Câmara
Reacted by Yasin Arık, gamestap99, Marc Liu, ruoyu2021, popsams, Sheena, Phạm Quốc Trọng, Pricx, icnahom, chenyang and 1 more
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.Affects or could affect many people, though not necessarily a specific customer.f: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7Found to occur in 3.7frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: duplicateIssue is closed as a duplicate of an existing issueIssue is closed as a duplicate of an existing issue
Activity
curls commentedon Aug 5, 2019
Hi,I have the same problem, how to fixed?
najeira commentedon Aug 5, 2019
I use PageStorage instead of AutomaticKeepAliveClientMixin to avoid this problem.
KorbinianMossandl commentedon Aug 29, 2019
@HansMuller i would like to bump this. Using PageStorage only works to some extend.
For example if you have a tab with an ExpansionPanelList.radio, it is not possible to save the currently expanded panel sate without AutomaticKeepAliveClientMixin or a custom rewrite of the whole widget just to be able to use PageStorage.
zmtzawqlp commentedon Dec 2, 2019
i have done some things to solve this thing, may be you have better solution 。please check it when you have the time.
i notice innerscrollcontrol is sync the cache scrollpostion, that the problem here.
may be we should only Focus on the active one
https://github.com/fluttercandies/extended_nested_scroll_view
VladyslavBondarenko commentedon Apr 3, 2020
Reproduced with
dev v1.16.4-pre.83marcusgregory commentedon Apr 6, 2020
I also encountered this problem, did anyone find a solution?
iapicca commentedon May 13, 2020
the issue reproduce with the latest master (1.19)
#57071 (comment)
lyf571321556 commentedon May 14, 2020
@iapicca This question has been raised for a long time. Are there any restoration plans in the near future
57 remaining items
iapicca commentedon Dec 14, 2022
@quangtuyen1993 imho this issue shouldn't be open at all, just use a
keyand everything works just fine (code sample)maRci002 commentedon Dec 14, 2022
This solution doesn't benefit from
NestedScrollViewsince Header won't be scrolled at all.maheshj01 commentedon Jan 14, 2023
Reproducible on stable 3.3 and master 3.7
code sample
logs
flutter doctor -v (mac)
Looks related to #62833
maRci002 commentedon Jan 30, 2023
Upvote #102003 issue to get priority.
I asked to add this issue also for
NestedScrollViewrewrite.maRci002 commentedon Feb 5, 2023
Here is a workaround which is based on #118713 (comment)
Check out DartPad (enabled touch events on desktop to simulate scroll by touch)
nestedscrollview_with_tabbar.mp4
DexEze commentedon May 26, 2023
This issue is still here today in 3.10
Piinks commentedon May 30, 2023
I think this is another case of #40740. I have been scanning the issue tracker looking to consolidate all of these so we can see about a proper solution. I am going to close this since #40740 has the most upvotes, let's follow up there. (I am adding a list there of issues like these to be linked)
Thanks for providing test cases, updates and work arounds! :)
github-actions commentedon Jun 19, 2023
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 -vand a minimal reproduction of the issue.