Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add animationDuration property to useTabController hook #446

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions packages/flutter_hooks/lib/src/tab_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ part of 'hooks.dart';
/// - [TabController]
TabController useTabController({
required int initialLength,
Duration? animationDuration = kTabScrollDuration,
TickerProvider? vsync,
int initialIndex = 0,
List<Object?>? keys,
Expand All @@ -17,6 +18,7 @@ TabController useTabController({
vsync: vsync,
length: initialLength,
initialIndex: initialIndex,
animationDuration: animationDuration,
keys: keys,
),
);
Expand All @@ -27,23 +29,24 @@ class _TabControllerHook extends Hook<TabController> {
required this.length,
required this.vsync,
required this.initialIndex,
List<Object?>? keys,
}) : super(keys: keys);
required this.animationDuration,
super.keys,
});

final int length;
final TickerProvider vsync;
final int initialIndex;
final Duration? animationDuration;

@override
HookState<TabController, Hook<TabController>> createState() =>
_TabControllerHookState();
HookState<TabController, Hook<TabController>> createState() => _TabControllerHookState();
}

class _TabControllerHookState
extends HookState<TabController, _TabControllerHook> {
class _TabControllerHookState extends HookState<TabController, _TabControllerHook> {
late final controller = TabController(
length: hook.length,
initialIndex: hook.initialIndex,
animationDuration: hook.animationDuration,
vsync: hook.vsync,
);

Expand Down