Repository navigation
TabBar with 1 tab exception #23077
Copy link
Copy link
Closed
Labels
frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packages
Description
I develop an app that has a tabbar with only 1 tab (for now, more will get added later) and when I try (by mistake) to scroll tabs, I get the following exception:
I/flutter (11089): ══╡ EXCEPTION CAUGHT BY ANIMATION LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (11089): The following assertion was thrown while notifying listeners for AnimationController:
I/flutter (11089): 'package:flutter/src/material/tab_controller.dart': Failed assertion: line 174 pos 12: 'length > 1':
I/flutter (11089): is not true.
I/flutter (11089): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (11089): more information in this error message to help you determine and fix the underlying cause.
I/flutter (11089): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (11089): https://github.com/flutter/flutter/issues/new
I/flutter (11089): When the exception was thrown, this was the stack:
I/flutter (11089): #2 TabController.offset= (package:flutter/src/material/tab_controller.dart:174:12)
I/flutter (11089): #3 _TabBarViewState._handleScrollNotification (package:flutter/src/material/tabs.dart:1172:19)
I/flutter (11089): #4 NotificationListener._dispatch (package:flutter/src/widgets/notification_listener.dart:125:27)
I/flutter (11089): #5 Notification.visitAncestor (package:flutter/src/widgets/notification_listener.dart:45:20)
I/flutter (11089): #6 _ScrollNotification&LayoutChangedNotification&ViewportNotificationMixin.visitAncestor (package:flutter/src/widgets/scroll_notification.dart:35:18)
I/flutter (11089): #7 Element.visitAncestorElements (package:flutter/src/widgets/framework.dart:3331:39)
I/flutter (11089): #8 Notification.dispatch (package:flutter/src/widgets/notification_listener.dart:59:12)
I/flutter (11089): #9 ScrollActivity.dispatchScrollUpdateNotification (package:flutter/src/widgets/scroll_activity.dart:96:92)
I/flutter (11089): #10 ScrollPosition.didUpdateScrollPositionBy (package:flutter/src/widgets/scroll_position.dart:632:14)
I/flutter (11089): #11 ScrollPosition.setPixels (package:flutter/src/widgets/scroll_position.dart:219:9)
I/flutter (11089): #12 ScrollPositionWithSingleContext.setPixels (package:flutter/src/widgets/scroll_position_with_single_context.dart:84:18)
I/flutter (11089): #13 BallisticScrollActivity.applyMoveTo (package:flutter/src/widgets/scroll_activity.dart:547:21)
I/flutter (11089): #14 BallisticScrollActivity._tick (package:flutter/src/widgets/scroll_activity.dart:534:10)
I/flutter (11089): #15 _AnimationController&Animation&AnimationEagerListenerMixin&AnimationLocalListenersMixin.notifyListeners (package:flutter/src/animation/listener_helpers.dart:136:19)
I/flutter (11089): #16 AnimationController._tick (package:flutter/src/animation/animation_controller.dart:693:5)
I/flutter (11089): #17 Ticker._tick (package:flutter/src/scheduler/ticker.dart:228:5)
I/flutter (11089): #18 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (11089): #19 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:906:11)
I/flutter (11089): #20 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.forEach (dart:collection/runtime/libcompact_hash.dart:370:8)
I/flutter (11089): #21 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame (package:flutter/src/scheduler/binding.dart:904:17)
I/flutter (11089): #22 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleBeginFrame (package:flutter/src/scheduler/binding.dart:834:5)
I/flutter (11089): #23 _invoke1 (dart:ui/hooks.dart:153:13)
I/flutter (11089): #24 _beginFrame (dart:ui/hooks.dart:123:3)
I/flutter (11089): (elided 2 frames from class _AssertionError)
I/flutter (11089): The AnimationController notifying listeners was:
I/flutter (11089): AnimationController#e5477(▶ 247.114; for BallisticScrollActivity)
I/flutter (11089): ════════════════════════════════════════════════════════════════════════════════════════════════════
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packages
Activity
rahulmanthena commentedon Oct 15, 2018
As the error says.. you need more than one tab for the tabbar to work. You can just add a tab with empty container in it for now to resolve this.
arthurgustin commentedon Oct 15, 2018
Yeh well in that case, I should not even be able to create the tabbar. The error occurs when I interact with it.
zoechi commentedon Oct 15, 2018
Please add the output of
flutter doctor -v.johnsonmh commentedon Apr 18, 2019
Looks like the
TabControllerhas been updated to allow forTabBars with only 1 tab in 123e9e0. This should resolve your issue!github-actions commentedon Aug 14, 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 -vand a minimal reproduction of the issue.