TabController constructor
- int initialIndex = 0,
- Duration? animationDuration,
- required int length,
- required TickerProvider vsync,
Creates an object that manages the state required by TabBar and a TabBarView.
The length
must not be negative. Typically it's a value greater than
one, i.e. typically there are two or more tabs. The length
must match
TabBar.tabs's and TabBarView.children's length.
The initialIndex
must be valid given length
. If length
is zero, then
initialIndex
must be 0 (the default).
Implementation
TabController({
int initialIndex = 0,
Duration? animationDuration,
required this.length,
required TickerProvider vsync,
}) : assert(length >= 0),
assert(initialIndex >= 0 && (length == 0 || initialIndex < length)),
_index = initialIndex,
_previousIndex = initialIndex,
_animationDuration = animationDuration ?? kTabScrollDuration,
_animationController = AnimationController.unbounded(
value: initialIndex.toDouble(),
vsync: vsync,
) {
if (kFlutterMemoryAllocationsEnabled) {
ChangeNotifier.maybeDispatchObjectCreation(this);
}
}