Skip to content

TabBar with 1 tab exception #23077

Closed
Closed

Description

@arthurgustin

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): ════════════════════════════════════════════════════════════════════════════════════════════════════

Activity

  1. rahulmanthena commented on Oct 15, 2018

    @rahulmanthena

    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.

  2. arthurgustin commented on Oct 15, 2018

    @arthurgustin
    Author

    Yeh well in that case, I should not even be able to create the tabbar. The error occurs when I interact with it.

  3. added
    c: crashStack traces logged to the console
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    on Oct 15, 2018
  4. added this to the milestone on Oct 15, 2018
  5. zoechi commented on Oct 15, 2018

    @zoechi
    Contributor

    Please add the output of flutter doctor -v.

  6. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Oct 15, 2018
  7. self-assigned this
    on Oct 15, 2018
  8. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Dec 18, 2018
  9. johnsonmh commented on Apr 18, 2019

    @johnsonmh
    Contributor

    Looks like the TabController has been updated to allow for TabBars with only 1 tab in 123e9e0. This should resolve your issue!

  10. github-actions commented on Aug 14, 2021

    @github-actions

    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.

  11. locked as resolved and limited conversation to collaborators on Aug 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    frameworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions