Skip to content

Replacing TabController mid-animation throws exception #34744

@shihaohong

Description

@shihaohong

When trying to dynamically update the number of tabs with a new TabController, an exception is thrown because the animation library attempts to reach an AnimationController that is no longer available.

Steps to Reproduce

Here's a gist with reproducible sample.

  1. Get the TabBarView or TabBar mid-animation
  2. Add/Remove tab while mid-animation

tab_controller_regression

Logs

I/flutter ( 4483): #12     ScrollPositionWithSingleContext.setPixels 
package:flutter/…/widgets/scroll_position_with_single_context.dart:83
I/flutter ( 4483): #13     BallisticScrollActivity.applyMoveTo 
package:flutter/…/widgets/scroll_activity.dart:547
I/flutter ( 4483): #14     BallisticScrollActivity._tick 
package:flutter/…/widgets/scroll_activity.dart:534
I/flutter ( 4483): #15     _AnimationController&Animation&AnimationEagerListenerMixin&AnimationLocalListenersMixin.notifyListeners 
package:flutter/…/animation/listener_helpers.dart:124
I/flutter ( 4483): #16     AnimationController._tick 
package:flutter/…/animation/animation_controller.dart:765
I/flutter ( 4483): #17     Ticker._tick 
package:flutter/…/scheduler/ticker.dart:228
I/flutter ( 4483): #18     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback 
package:flutter/…/scheduler/binding.dart:1016
I/flutter ( 4483): #19     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame.<anonymous closure> 
package:flutter/…/scheduler/binding.dart:934
I/flutter ( 4483): #20     __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.forEach  (dart:collection-patch/compact_hash.dart:367:8)
I/flutter ( 4483): #21     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame 
package:flutter/…/scheduler/binding.dart:932
I/flutter ( 4483): #22     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleBeginFrame 
package:flutter/…/scheduler/binding.dart:866
I/flutter ( 4483): #26     _invoke1  (dart:ui/hooks.dart:250:10)
I/flutter ( 4483): #27     _beginFrame  (dart:ui/hooks.dart:177:3)
I/flutter ( 4483): (elided 3 frames from package dart:async)
I/flutter ( 4483):
I/flutter ( 4483): The AnimationController notifying listeners was:
I/flutter ( 4483):   AnimationController#a39b9(▶ 343.604; for BallisticScrollActivity)
I/flutter ( 4483): ════════════════════════════════════════════════════════════════════════════════════════════════════

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: null-safetySupport for Dart's null safety featurec: regressionIt was better in the past than it is nowf: material designflutter/packages/flutter/material repository.f: scrollingViewports, list views, slivers, etc.found in release: 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions