-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.f: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 2.8Found to occur in 2.8Found to occur in 2.8found in release: 2.9Found to occur in 2.9Found to occur in 2.9frameworkflutter/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 onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
TabBar with isScrollable is true never scroll to current index when controller is changed, however when TabBar is forced to make fresh new state with key, it will go to current index.
Steps to Reproduce
- Run project above
- On 1st nav bar, go to last tab
- Switch to 2nd nav bar
- Switch back to 1st nav bar
- Rerun the project again but uncomment this part
appBar: AppBar(
title: const Text('Tab Demo'),
bottom: TabBar(
key: ValueKey('TabBar-$_index'), // Uncomment this
isScrollable: true,
controller: _controllers[_index],
tabs: _tabGroups[_index],
),
),Expected results: TabBar scroll to current on controller changed
Actual results: TabBar didn't scroll to current on controller changed
Logs
[√] Flutter (Channel master, 2.9.0-1.0.pre.384, on Microsoft Windows [Version 10.0.22000.434], locale en-001)
• Flutter version 2.9.0-1.0.pre.384 at C:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision a3fd36a115 (2 days ago), 2022-01-14 20:40:17 -0500
• Engine revision 83d99a5809
• Dart version 2.17.0 (build 2.17.0-16.0.dev)
• DevTools version 2.9.2
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at C:\Users\andre\AppData\Local\Android\sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.9)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.11.32106.194
• Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2020.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[√] VS Code (version 1.63.2)
• VS Code at C:\Users\andre\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.32.0
[√] Connected device (4 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 12 (API 31) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22000.434]
• Chrome (web) • chrome • web-javascript • Google Chrome 97.0.4692.71
• Edge (web) • edge • web-javascript • Microsoft Edge 97.0.1072.62
[√] HTTP Host Availability
• All required HTTP hosts are available
R01ZiMJROW.mp4
The issue is the state doesn't call scrollToCurrentIndex on here
flutter/packages/flutter/lib/src/material/tabs.dart
Lines 963 to 967 in a3fd36a
| if (_controller != null) { | |
| _controller!.animation!.addListener(_handleTabControllerAnimationTick); | |
| _controller!.addListener(_handleTabControllerTick); | |
| _currentIndex = _controller!.index; | |
| } |
adding this code after _currentIndex = _controller!.index; might fixed it, but I haven't test what happen if the controller has different length
// Scroll to new controller active index
if (widget.isScrollable && _scrollController != null) _scrollToCurrentIndex();Metadata
Metadata
Assignees
Labels
f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.f: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 2.8Found to occur in 2.8Found to occur in 2.8found in release: 2.9Found to occur in 2.9Found to occur in 2.9frameworkflutter/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 onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Type
Projects
Status
Done (PR merged)