File tree 3 files changed +29
-5
lines changed
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'
7
7
CarouselController,
8
8
DraggableScrollableController,
9
9
ExpansionTileController,
10
- WidgetStatesController,
11
10
SearchController,
12
11
TabController,
13
- TreeSliverController,
14
- WidgetState;
12
+ WidgetState,
13
+ WidgetStatesController,
14
+ kTabScrollDuration;
15
15
import 'package:flutter/scheduler.dart' ;
16
16
import 'package:flutter/widgets.dart' ;
17
17
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ part of 'hooks.dart';
6
6
/// - [TabController]
7
7
TabController useTabController ({
8
8
required int initialLength,
9
+ Duration ? animationDuration = kTabScrollDuration,
9
10
TickerProvider ? vsync,
10
11
int initialIndex = 0 ,
11
12
List <Object ?>? keys,
@@ -17,6 +18,7 @@ TabController useTabController({
17
18
vsync: vsync,
18
19
length: initialLength,
19
20
initialIndex: initialIndex,
21
+ animationDuration: animationDuration,
20
22
keys: keys,
21
23
),
22
24
);
@@ -27,12 +29,14 @@ class _TabControllerHook extends Hook<TabController> {
27
29
required this .length,
28
30
required this .vsync,
29
31
required this .initialIndex,
30
- List <Object ?>? keys,
31
- }) : super (keys: keys);
32
+ required this .animationDuration,
33
+ super .keys,
34
+ });
32
35
33
36
final int length;
34
37
final TickerProvider vsync;
35
38
final int initialIndex;
39
+ final Duration ? animationDuration;
36
40
37
41
@override
38
42
HookState <TabController , Hook <TabController >> createState () =>
@@ -44,6 +48,7 @@ class _TabControllerHookState
44
48
late final controller = TabController (
45
49
length: hook.length,
46
50
initialIndex: hook.initialIndex,
51
+ animationDuration: hook.animationDuration,
47
52
vsync: hook.vsync,
48
53
);
49
54
Original file line number Diff line number Diff line change @@ -138,6 +138,25 @@ void main() {
138
138
verifyNoMoreInteractions (vsync);
139
139
ticker.dispose ();
140
140
});
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
+ });
141
160
});
142
161
}
143
162
You can’t perform that action at this time.
0 commit comments