From f788714336ea6b61bdae5c54a6afdacb5ae32c76 Mon Sep 17 00:00:00 2001 From: Henry Riehl Date: Wed, 9 Aug 2023 00:07:02 +0100 Subject: [PATCH 1/4] init commit --- packages/flutter/lib/src/material/ink_well.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/ink_well.dart b/packages/flutter/lib/src/material/ink_well.dart index 157e2b31884a..80ff99b56d8a 100644 --- a/packages/flutter/lib/src/material/ink_well.dart +++ b/packages/flutter/lib/src/material/ink_well.dart @@ -332,6 +332,7 @@ class InkResponse extends StatelessWidget { this.onFocusChange, this.autofocus = false, this.statesController, + this.hoverDuration = const Duration(milliseconds: 50), }); /// The widget below this widget in the tree. @@ -621,6 +622,9 @@ class InkResponse extends StatelessWidget { /// {@endtemplate} final MaterialStatesController? statesController; + /// The duration of the animation that animates the hover effect. + final Duration hoverDuration; + @override Widget build(BuildContext context) { final _ParentInkResponseState? parentState = _ParentInkResponseProvider.maybeOf(context); @@ -659,6 +663,7 @@ class InkResponse extends StatelessWidget { getRectCallback: getRectCallback, debugCheckContext: debugCheckContext, statesController: statesController, + hoverDuration: hoverDuration, child: child, ); } @@ -715,6 +720,7 @@ class _InkResponseStateWidget extends StatefulWidget { this.getRectCallback, required this.debugCheckContext, this.statesController, + this.hoverDuration = const Duration(milliseconds: 50), }); final Widget? child; @@ -752,6 +758,7 @@ class _InkResponseStateWidget extends StatefulWidget { final _GetRectCallback? getRectCallback; final _CheckContext debugCheckContext; final MaterialStatesController? statesController; + final Duration hoverDuration; @override _InkResponseState createState() => _InkResponseState(); @@ -920,7 +927,7 @@ class _InkResponseState extends State<_InkResponseStateWidget> return const Duration(milliseconds: 200); case _HighlightType.hover: case _HighlightType.focus: - return const Duration(milliseconds: 50); + return widget.hoverDuration; } } @@ -1456,6 +1463,7 @@ class InkWell extends InkResponse { super.onFocusChange, super.autofocus, super.statesController, + super.hoverDuration, }) : super( containedInkWell: true, highlightShape: BoxShape.rectangle, From f05e93a83f7e27abcd401bbb61611248bf9022f7 Mon Sep 17 00:00:00 2001 From: Henry Riehl Date: Wed, 9 Aug 2023 00:21:02 +0100 Subject: [PATCH 2/4] add test --- .../flutter/test/material/ink_well_test.dart | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/flutter/test/material/ink_well_test.dart b/packages/flutter/test/material/ink_well_test.dart index e444b00a9f10..e3255db58f79 100644 --- a/packages/flutter/test/material/ink_well_test.dart +++ b/packages/flutter/test/material/ink_well_test.dart @@ -2230,4 +2230,28 @@ testWidgetsWithLeakTracking('InkResponse radius can be updated', (WidgetTester t await gesture.up(); }); + + testWidgetsWithLeakTracking('try out hoverDuration property', (WidgetTester tester) async { + final List log = []; + + await tester.pumpWidget(Directionality( + textDirection: TextDirection.ltr, + child: Material( + child: Center( + child: InkWell( + hoverDuration: const Duration(milliseconds: 1000), + onTap: () { + log.add('tap'); + }, + ), + ), + ), + )); + + await tester.tap(find.byType(InkWell), pointer: 1); + await tester.pump(const Duration(seconds: 1)); + + expect(log, equals(['tap'])); + log.clear(); + }); } From c6720e82a80e02de09d6e684109743c8d16cff6c Mon Sep 17 00:00:00 2001 From: Henry Riehl Date: Wed, 9 Aug 2023 20:36:00 +0100 Subject: [PATCH 3/4] make hoverDuration null --- packages/flutter/lib/src/material/ink_well.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/flutter/lib/src/material/ink_well.dart b/packages/flutter/lib/src/material/ink_well.dart index 80ff99b56d8a..dd188965c934 100644 --- a/packages/flutter/lib/src/material/ink_well.dart +++ b/packages/flutter/lib/src/material/ink_well.dart @@ -332,7 +332,7 @@ class InkResponse extends StatelessWidget { this.onFocusChange, this.autofocus = false, this.statesController, - this.hoverDuration = const Duration(milliseconds: 50), + this.hoverDuration, }); /// The widget below this widget in the tree. @@ -623,7 +623,7 @@ class InkResponse extends StatelessWidget { final MaterialStatesController? statesController; /// The duration of the animation that animates the hover effect. - final Duration hoverDuration; + final Duration? hoverDuration; @override Widget build(BuildContext context) { @@ -720,7 +720,7 @@ class _InkResponseStateWidget extends StatefulWidget { this.getRectCallback, required this.debugCheckContext, this.statesController, - this.hoverDuration = const Duration(milliseconds: 50), + this.hoverDuration, }); final Widget? child; @@ -758,7 +758,7 @@ class _InkResponseStateWidget extends StatefulWidget { final _GetRectCallback? getRectCallback; final _CheckContext debugCheckContext; final MaterialStatesController? statesController; - final Duration hoverDuration; + final Duration? hoverDuration; @override _InkResponseState createState() => _InkResponseState(); @@ -927,7 +927,7 @@ class _InkResponseState extends State<_InkResponseStateWidget> return const Duration(milliseconds: 200); case _HighlightType.hover: case _HighlightType.focus: - return widget.hoverDuration; + return widget.hoverDuration ?? const Duration(milliseconds: 50); } } From ccb62f54ad9c8d20e1f1e7f4036bdd415ba5d284 Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Mon, 21 Aug 2023 10:00:23 -0700 Subject: [PATCH 4/4] Update packages/flutter/lib/src/material/ink_well.dart --- packages/flutter/lib/src/material/ink_well.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/flutter/lib/src/material/ink_well.dart b/packages/flutter/lib/src/material/ink_well.dart index dd188965c934..8814a847ad1c 100644 --- a/packages/flutter/lib/src/material/ink_well.dart +++ b/packages/flutter/lib/src/material/ink_well.dart @@ -623,6 +623,8 @@ class InkResponse extends StatelessWidget { final MaterialStatesController? statesController; /// The duration of the animation that animates the hover effect. + /// + /// The default is 50ms. final Duration? hoverDuration; @override