-
Notifications
You must be signed in to change notification settings - Fork 26.7k
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
Removed Tab from TabController is still scrollable by swiping in the TabBarView #43190
Labels
a: quality
A truly polished experience
f: material design
flutter/packages/flutter/material repository.
f: scrolling
Viewports, list views, slivers, etc.
found in release: 3.3
Found to occur in 3.3
found in release: 3.7
Found to occur in 3.7
framework
flutter/packages/flutter repository. See also f: labels.
has reproducible steps
The issue has been confirmed reproducible and is ready to work on
P2
Important issues not at the top of the work list
team-design
Owned by Design Languages team
triaged-design
Triaged by Design Languages team
Comments
HansMuller
added
f: material design
flutter/packages/flutter/material repository.
framework
flutter/packages/flutter repository. See also f: labels.
labels
Oct 21, 2019
Would love to hear some feedback from you guys. Are these expected issues? Or I am doing something wrong there? Cheers |
Come on guys after 2 months not even one comment? That sucks! |
TahaTesser
changed the title
Flutter and Dynamic TabBar with TabBarView
Removed Tab from TabController is still scrollable by swiping in the TabBarView
Apr 21, 2020
Issue still exists code sampleimport 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MainPage());
}
}
class MainPage extends StatefulWidget {
@override
_MainPageState createState() => _MainPageState();
}
class _MainPageState extends State<MainPage> with TickerProviderStateMixin {
final int _startingTabCount = 4;
List<Tab> _tabs = List<Tab>();
List<Widget> _generalWidgets = List<Widget>();
TabController _tabController;
@override
void initState() {
_tabs = getTabs(_startingTabCount);
_tabController = getTabController();
super.initState();
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Dynamic TBV"),
bottom: TabBar(
tabs: _tabs,
controller: _tabController,
),
actions: <Widget>[
IconButton(
icon: Icon(Icons.add),
onPressed: _addAnotherTab,
),
IconButton(
icon: Icon(Icons.remove),
onPressed: _removeTab,
),
],
),
body: TabBarView(
controller: _tabController,
children: getWidgets(),
),
);
}
TabController getTabController() {
return TabController(length: _tabs.length, vsync: this);
}
Tab getTab(int widgetNumber) {
return Tab(
text: "$widgetNumber",
);
}
Widget getWidget(int widgetNumber) {
return Center(
child: Text("Widget nr: $widgetNumber"),
);
}
List<Tab> getTabs(int count) {
_tabs.clear();
for (int i = 0; i < count; i++) {
_tabs.add(getTab(i));
}
return _tabs;
}
List<Widget> getWidgets() {
_generalWidgets.clear();
for (int i = 0; i < _tabs.length; i++) {
_generalWidgets.add(getWidget(i));
}
return _generalWidgets;
}
void _addAnotherTab() {
_tabs = getTabs(_tabs.length + 1);
_tabController.index = 0;
_tabController = getTabController();
_updatePage();
}
void _removeTab() {
_tabs = getTabs(_tabs.length - 1);
_tabController.index = 0;
_tabController = getTabController();
_updatePage();
}
void _updatePage() {
setState(() {});
}
}
flutter doctor -v[✓] Flutter (Channel dev, v1.18.0-dev.5.0, on Mac OS X 10.15.4 19E287, locale
en-GB)
• Flutter version 1.18.0-dev.5.0 at /Users/taha/Code/flutter_dev
• Framework revision 7f56b53de4 (9 days ago), 2020-04-12 12:00:01 -0400
• Engine revision beb8a7ec48
• Dart version 2.8.0 (build 2.8.0-dev.20.0 89b0f67261)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/taha/Code/sdk
• Platform android-29, build-tools 29.0.3
• ANDROID_HOME = /Users/taha/Code/sdk
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.4.1, Build version 11E503a
• CocoaPods version 1.9.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 45.1.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b4-5784211)
[✓] VS Code (version 1.44.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.9.1
[✓] Connected device (4 available)
• SM M305F • 32003c30dc19668f • android-arm64 • Android 10 (API 29)
• macOS • macOS • darwin-x64 • Mac OS X 10.15.4 19E287
• Chrome • chrome • web-javascript • Google Chrome
81.0.4044.113
• Web Server • web-server • web-javascript • Flutter Tools
• No issues found!
taha@MacBook-Pro ~ % flutterd doctor -v
[✓] Flutter (Channel dev, v1.18.0-dev.5.0, on Mac OS X 10.15.4 19E287, locale
en-GB)
• Flutter version 1.18.0-dev.5.0 at /Users/taha/Code/flutter_dev
• Framework revision 7f56b53de4 (9 days ago), 2020-04-12 12:00:01 -0400
• Engine revision beb8a7ec48
• Dart version 2.8.0 (build 2.8.0-dev.20.0 89b0f67261)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/taha/Code/sdk
• Platform android-29, build-tools 29.0.3
• ANDROID_HOME = /Users/taha/Code/sdk
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.4.1, Build version 11E503a
• CocoaPods version 1.9.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 45.1.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b4-5784211)
[✓] VS Code (version 1.44.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.9.1
[✓] Connected device (5 available)
• SM M305F • 32003c30dc19668f • android-arm64 •
Android 10 (API 29)
• iPhone 11 • 41EB2A85-7EB4-4FD2-8978-FBBE2A681D74 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-13-4 (simulator)
• macOS • macOS • darwin-x64 • Mac
OS X 10.15.4 19E287
• Chrome • chrome • web-javascript •
Google Chrome 81.0.4044.113
• Web Server • web-server • web-javascript •
Flutter Tools
• No issues found! Restarted application in 619ms.
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: 'package:flutter/src/material/tab_controller.dart': Failed assertion: line 155 pos 12: 'value >= 0 && (value < length || length == 0)': is not true.
�[38;5;244m#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:42:39)�[39;49m
�[38;5;244m#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:38:5)�[39;49m
�[38;5;244m#2 TabController._changeIndex�[39;49m
�[38;5;244m#3 TabController.index=�[39;49m
�[38;5;244m#4 _TabBarViewState._handleScrollNotification�[39;49m
�[38;5;244m#5 NotificationListener._dispatch�[39;49m
�[38;5;244m#6 Notification.visitAncestor�[39;49m
�[38;5;244m#7 ViewportNotificationMixin.visitAncestor�[39;49m
#8 Element.visitAncestorElements (package:flutter/src/widgets/fr<…>
|
TahaTesser
added
a: quality
A truly polished experience
f: scrolling
Viewports, list views, slivers, etc.
has reproducible steps
The issue has been confirmed reproducible and is ready to work on
labels
Apr 21, 2020
TahaTesser
added
found in release: 1.19
Found to occur in 1.19
found in release: 1.18
Occurs in 1.18
and removed
found in release: 1.19
Found to occur in 1.19
labels
Jul 30, 2020
flutter doctor -v[✓] Flutter (Channel stable, 1.22.5, on macOS 11.1 20C69 darwin-x64, locale en-GB)
• Flutter version 1.22.5 at /Users/tahatesser/Code/flutter_stable
• Framework revision 7891006299 (4 weeks ago), 2020-12-10 11:54:40 -0800
• Engine revision ae90085a84
• Dart version 2.10.4
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Volumes/Extreme/sdk
• Platform android-30, build-tools 30.0.3
• ANDROID_HOME = /Volumes/Extreme/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
• Xcode at /Volumes/Extreme/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.10.0
[!] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.52.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.18.0
[✓] Connected device (2 available)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
• Taha’s iPad (mobile) • 00008020-000255113EE8402E • ios • iOS 14.3
! Doctor found issues in 1 category. [✓] Flutter (Channel master, 1.26.0-2.0.pre.200, on macOS 11.1 20C69 darwin-x64, locale en-GB)
• Flutter version 1.26.0-2.0.pre.200 at /Users/tahatesser/Code/flutter_master
• Framework revision d0e9959a46 (11 hours ago), 2021-01-05 22:14:03 -0500
• Engine revision e115066dcd
• Dart version 2.12.0 (build 2.12.0-179.0.dev)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Volumes/Extreme/sdk
• Platform android-30, build-tools 30.0.3
• ANDROID_HOME = /Volumes/Extreme/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
• Xcode at /Volumes/Extreme/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.10.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• 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 1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.52.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.18.0
[✓] Connected device (4 available)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
• Taha’s iPad (mobile) • 00008020-000255113EE8402E • ios • iOS 14.3
• macOS (desktop) • macos • darwin-x64 • macOS 11.1 20C69 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 87.0.4280.88
• No issues found! |
TahaTesser
added
found in release: 1.22
Found to occur in 1.22
found in release: 1.26
Found to occur in 1.26
and removed
found in release: 1.18
Occurs in 1.18
labels
Jan 6, 2021
Reproducible on the stable 3.3 and the master 3.7. code sampleimport 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MainPage());
}
}
class MainPage extends StatefulWidget {
@override
_MainPageState createState() => _MainPageState();
}
class _MainPageState extends State<MainPage> with TickerProviderStateMixin {
final int _startingTabCount = 4;
List<Tab> _tabs = <Tab>[];
final List<Widget> _generalWidgets = <Widget>[];
late TabController _tabController;
@override
void initState() {
_tabs = getTabs(_startingTabCount);
_tabController = getTabController();
super.initState();
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Dynamic TBV"),
bottom: TabBar(
tabs: _tabs,
controller: _tabController,
),
actions: <Widget>[
IconButton(
icon: Icon(Icons.add),
onPressed: _addAnotherTab,
),
IconButton(
icon: Icon(Icons.remove),
onPressed: _removeTab,
),
],
),
body: TabBarView(
controller: _tabController,
children: getWidgets(),
),
);
}
TabController getTabController() {
return TabController(length: _tabs.length, vsync: this);
}
Tab getTab(int widgetNumber) {
return Tab(
text: "$widgetNumber",
);
}
Widget getWidget(int widgetNumber) {
return Center(
child: Text("Widget nr: $widgetNumber"),
);
}
List<Tab> getTabs(int count) {
_tabs.clear();
for (int i = 0; i < count; i++) {
_tabs.add(getTab(i));
}
return _tabs;
}
List<Widget> getWidgets() {
_generalWidgets.clear();
for (int i = 0; i < _tabs.length; i++) {
_generalWidgets.add(getWidget(i));
}
return _generalWidgets;
}
void _addAnotherTab() {
_tabs = getTabs(_tabs.length + 1);
_tabController.index = 0;
_tabController = getTabController();
_updatePage();
}
void _removeTab() {
_tabs = getTabs(_tabs.length - 1);
_tabController.index = 0;
_tabController = getTabController();
_updatePage();
}
void _updatePage() {
setState(() {});
}
} logsRestarted application in 483ms.
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/material/tab_controller.dart': Failed assertion: line 181 pos 12: 'value >= 0 && (value < length || length == 0)': is not true.
#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2 TabController._changeIndex (package:flutter/src/material/tab_controller.dart:181:12)
#3 TabController.index= (package:flutter/src/material/tab_controller.dart:220:5)
#4 _TabBarViewState._handleScrollNotification (package:flutter/src/material/tabs.dart:1647:20)
#5 _NotificationElement.onNotification (package:flutter/src/widgets/notification_listener.dart:130:38)
#6 _NotificationNode.dispatchNotification (package:flutter/src/widgets/framework.dart:3170:18)
#7 _NotificationNode.dispatchNotification (package:flutter/src/widgets/framework.dart:3173:13)
#8 _NotificationNode.dispatchNotification (package:flutter/sr<…>
flutter doctor -v (mac)
|
maheshmnj
added
found in release: 3.3
Found to occur in 3.3
found in release: 3.7
Found to occur in 3.7
and removed
found in release: 1.22
Found to occur in 1.22
found in release: 1.26
Found to occur in 1.26
labels
Dec 7, 2022
flutter-triage-bot
bot
added
multiteam-retriage-candidate
team-design
Owned by Design Languages team
triaged-design
Triaged by Design Languages team
labels
Jul 8, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
a: quality
A truly polished experience
f: material design
flutter/packages/flutter/material repository.
f: scrolling
Viewports, list views, slivers, etc.
found in release: 3.3
Found to occur in 3.3
found in release: 3.7
Found to occur in 3.7
framework
flutter/packages/flutter repository. See also f: labels.
has reproducible steps
The issue has been confirmed reproducible and is ready to work on
P2
Important issues not at the top of the work list
team-design
Owned by Design Languages team
triaged-design
Triaged by Design Languages team
Hey guys,
I've been writing a tutorial about Dynamic TabBar and TabBarView and I discovered something interesting. It seems somehow Widgets are cached while they are dynamically removed.
Repo - https://github.com/zeromaro/dynamic-tab-bar-view/tree/tbv-basic .
Log below
This is first part of discovery.
Second part is that now we have 3 tabs. Originally we had 4 tabs. Let's click + sign two times. Second time our UI will overflow.
I'm not sure it's expected or not.
Flutter Doctor
Cheers
The text was updated successfully, but these errors were encountered: