Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2dbd2d5

Browse filesBrowse files
committed
2 parents 6a6daf2 + 239c387 commit 2dbd2d5
Copy full SHA for 2dbd2d5

File tree

Expand file treeCollapse file tree

3 files changed

+29
-5
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+29
-5
lines changed

‎packages/flutter_hooks/lib/src/hooks.dart

Copy file name to clipboardExpand all lines: packages/flutter_hooks/lib/src/hooks.dart
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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;
1515
import 'package:flutter/scheduler.dart';
1616
import 'package:flutter/widgets.dart';
1717

‎packages/flutter_hooks/lib/src/tab_controller.dart

Copy file name to clipboardExpand all lines: packages/flutter_hooks/lib/src/tab_controller.dart
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ part of 'hooks.dart';
66
/// - [TabController]
77
TabController 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

‎packages/flutter_hooks/test/use_tab_controller_test.dart

Copy file name to clipboardExpand all lines: packages/flutter_hooks/test/use_tab_controller_test.dart
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.