useTabController function

TabController useTabController({
  1. required int length,
  2. TickerProvider? vsync,
  3. int initialIndex = 0,
  4. Duration? animationDuration,
})

Creates a TabController.

The controller is automatically disposed when the widget is unmounted.

Implementation

TabController useTabController({
  /// An optional [vsync] parameter to synchronize the tab animations.
  /// If not provided, a ticker will be created automatically.
  required int length,
  TickerProvider? vsync,
  int initialIndex = 0,
  Duration? animationDuration,
}) {
  vsync ??= useSingleTickerState();
  final c = TabController(
    length: length,
    vsync: vsync,
    initialIndex: initialIndex,
    animationDuration: animationDuration,
  );
  onBeforeUnmount(c.dispose);
  return c;
}