File tree Expand file tree Collapse file tree 3 files changed +29
-5
lines changed
Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -7,11 +7,11 @@ import 'package:flutter/material.dart'
77 CarouselController,
88 DraggableScrollableController,
99 ExpansionTileController,
10- WidgetStatesController,
1110 SearchController,
1211 TabController,
13- TreeSliverController,
14- WidgetState;
12+ WidgetState,
13+ WidgetStatesController,
14+ kTabScrollDuration;
1515import 'package:flutter/scheduler.dart' ;
1616import 'package:flutter/widgets.dart' ;
1717
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ part of 'hooks.dart';
66/// - [TabController]
77TabController useTabController ({
88 required int initialLength,
9+ Duration ? animationDuration = kTabScrollDuration,
910 TickerProvider ? vsync,
1011 int initialIndex = 0 ,
1112 List <Object ?>? keys,
@@ -17,6 +18,7 @@ TabController useTabController({
1718 vsync: vsync,
1819 length: initialLength,
1920 initialIndex: initialIndex,
21+ animationDuration: animationDuration,
2022 keys: keys,
2123 ),
2224 );
@@ -27,12 +29,14 @@ class _TabControllerHook extends Hook<TabController> {
2729 required this .length,
2830 required this .vsync,
2931 required this .initialIndex,
30- List <Object ?>? keys,
31- }) : super (keys: keys);
32+ required this .animationDuration,
33+ super .keys,
34+ });
3235
3336 final int length;
3437 final TickerProvider vsync;
3538 final int initialIndex;
39+ final Duration ? animationDuration;
3640
3741 @override
3842 HookState <TabController , Hook <TabController >> createState () =>
@@ -44,6 +48,7 @@ class _TabControllerHookState
4448 late final controller = TabController (
4549 length: hook.length,
4650 initialIndex: hook.initialIndex,
51+ animationDuration: hook.animationDuration,
4752 vsync: hook.vsync,
4853 );
4954
Original file line number Diff line number Diff line change @@ -138,6 +138,25 @@ void main() {
138138 verifyNoMoreInteractions (vsync);
139139 ticker.dispose ();
140140 });
141+
142+ testWidgets ('initial animationDuration matches with real constructor' ,
143+ (tester) async {
144+ late TabController controller;
145+ late TabController controller2;
146+
147+ await tester.pumpWidget (
148+ HookBuilder (
149+ builder: (context) {
150+ final vsync = useSingleTickerProvider ();
151+ controller = useTabController (initialLength: 4 );
152+ controller2 = TabController (length: 4 , vsync: vsync);
153+ return Container ();
154+ },
155+ ),
156+ );
157+
158+ expect (controller.animationDuration, controller2.animationDuration);
159+ });
141160 });
142161}
143162
You can’t perform that action at this time.
0 commit comments