MotionTabBarController class

A TabController that also notifies a MotionTabBar when its index is changed programmatically.

Use this instead of a plain TabController when you need to change the selected tab from outside the tab bar (e.g. from a button or another widget), so that the tab bar animates to the new tab.

Example:

final controller = MotionTabBarController(
  initialIndex: 1,
  length: 4,
  vsync: this,
);

// Change the selected tab programmatically:
controller.index = 2;
Inheritance

Constructors

MotionTabBarController({int initialIndex = 0, Duration? animationDuration, required int length, required TickerProvider vsync})
Creates a MotionTabBarController.

Properties

animation → Animation<double>?
An animation whose value represents the current position of the TabBar's selected tab indicator as well as the scrollOffsets of the TabBar and TabBarView.
no setterinherited
animationDuration → Duration
Controls the duration of TabController and TabBarView animations.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any listeners are currently registered.
no setterinherited
index ↔ int
The index of the currently selected tab.
getter/setter pairinherited-getteroverride-setter
indexIsChanging → bool
True while we're animating from previousIndex to index as a consequence of calling animateTo.
no setterinherited
length → int
The total number of tabs.
finalinherited
offset ↔ double
The difference between the animation's value and index.
getter/setter pairinherited
onTabChange ← dynamic Function(int)?
Sets the callback invoked whenever the tab index changes.
no getter
previousIndex → int
The index of the previously selected tab.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
animateTo(int value, {Duration? duration, Curve curve = Curves.ease}) → void
Immediately sets index and previousIndex and then plays the animation from its current value to index.
inherited
dispose() → void
Discards any resources used by the object.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited