TabController constructor Null safety
- {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 null or 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 and must not be null. 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 != null && length >= 0),
assert(initialIndex != null && initialIndex >= 0 && (length == 0 || initialIndex < length)),
_index = initialIndex,
_previousIndex = initialIndex,
_animationDuration = animationDuration ?? kTabScrollDuration,
_animationController = AnimationController.unbounded(
value: initialIndex.toDouble(),
vsync: vsync,
);