Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
ad7322dd
Unverified
Commit
ad7322dd
authored
Jan 10, 2023
by
Bruno Leroux
Committed by
GitHub
Jan 10, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide InkWell hover highlight when an hovered InkWell is disabled (#118026)
parent
466cb546
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
8 deletions
+65
-8
ink_well.dart
packages/flutter/lib/src/material/ink_well.dart
+14
-7
ink_well_test.dart
packages/flutter/test/material/ink_well_test.dart
+50
-0
list_tile_test.dart
packages/flutter/test/material/list_tile_test.dart
+1
-1
No files found.
packages/flutter/lib/src/material/ink_well.dart
View file @
ad7322dd
...
@@ -842,14 +842,14 @@ class _InkResponseState extends State<_InkResponseStateWidget>
...
@@ -842,14 +842,14 @@ class _InkResponseState extends State<_InkResponseStateWidget>
widget
.
radius
!=
oldWidget
.
radius
||
widget
.
radius
!=
oldWidget
.
radius
||
widget
.
borderRadius
!=
oldWidget
.
borderRadius
||
widget
.
borderRadius
!=
oldWidget
.
borderRadius
||
widget
.
highlightShape
!=
oldWidget
.
highlightShape
)
{
widget
.
highlightShape
!=
oldWidget
.
highlightShape
)
{
final
InkHighlight
?
hoverHigh
L
ight
=
_highlights
[
_HighlightType
.
hover
];
final
InkHighlight
?
hoverHigh
l
ight
=
_highlights
[
_HighlightType
.
hover
];
if
(
hoverHigh
L
ight
!=
null
)
{
if
(
hoverHigh
l
ight
!=
null
)
{
hoverHigh
L
ight
.
dispose
();
hoverHigh
l
ight
.
dispose
();
updateHighlight
(
_HighlightType
.
hover
,
value:
_hovering
,
callOnHover:
false
);
updateHighlight
(
_HighlightType
.
hover
,
value:
_hovering
,
callOnHover:
false
);
}
}
final
InkHighlight
?
focusHigh
L
ight
=
_highlights
[
_HighlightType
.
focus
];
final
InkHighlight
?
focusHigh
l
ight
=
_highlights
[
_HighlightType
.
focus
];
if
(
focusHigh
L
ight
!=
null
)
{
if
(
focusHigh
l
ight
!=
null
)
{
focusHigh
L
ight
.
dispose
();
focusHigh
l
ight
.
dispose
();
// Do not call updateFocusHighlights() here because it is called below
// Do not call updateFocusHighlights() here because it is called below
}
}
}
}
...
@@ -857,6 +857,13 @@ class _InkResponseState extends State<_InkResponseStateWidget>
...
@@ -857,6 +857,13 @@ class _InkResponseState extends State<_InkResponseStateWidget>
statesController
.
update
(
MaterialState
.
disabled
,
!
enabled
);
statesController
.
update
(
MaterialState
.
disabled
,
!
enabled
);
if
(!
enabled
)
{
if
(!
enabled
)
{
statesController
.
update
(
MaterialState
.
pressed
,
false
);
statesController
.
update
(
MaterialState
.
pressed
,
false
);
// Remove the existing hover highlight immediately when enabled is false.
// Do not rely on updateHighlight or InkHighlight.deactivate to not break
// the expected lifecycle which is updating _hovering when the mouse exit.
// Manually updating _hovering here or calling InkHighlight.deactivate
// will lead to onHover not being called or call when it is not allowed.
final
InkHighlight
?
hoverHighlight
=
_highlights
[
_HighlightType
.
hover
];
hoverHighlight
?.
dispose
();
}
}
// Don't call widget.onHover because many widgets, including the button
// Don't call widget.onHover because many widgets, including the button
// widgets, apply setState to an ancestor context from onHover.
// widgets, apply setState to an ancestor context from onHover.
...
@@ -937,7 +944,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
...
@@ -937,7 +944,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
_highlights
[
type
]
=
InkHighlight
(
_highlights
[
type
]
=
InkHighlight
(
controller:
Material
.
of
(
context
),
controller:
Material
.
of
(
context
),
referenceBox:
referenceBox
,
referenceBox:
referenceBox
,
color:
resolvedOverlayColor
,
color:
enabled
?
resolvedOverlayColor
:
resolvedOverlayColor
.
withAlpha
(
0
)
,
shape:
widget
.
highlightShape
,
shape:
widget
.
highlightShape
,
radius:
widget
.
radius
,
radius:
widget
.
radius
,
borderRadius:
widget
.
borderRadius
,
borderRadius:
widget
.
borderRadius
,
...
...
packages/flutter/test/material/ink_well_test.dart
View file @
ad7322dd
...
@@ -1722,6 +1722,56 @@ testWidgets('InkResponse radius can be updated', (WidgetTester tester) async {
...
@@ -1722,6 +1722,56 @@ testWidgets('InkResponse radius can be updated', (WidgetTester tester) async {
expect
(
hover
,
false
);
expect
(
hover
,
false
);
});
});
testWidgets
(
'hovered ink well draws a transparent highlight when disabled'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
({
required
bool
enabled
})
{
return
Material
(
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
SizedBox
(
width:
100
,
height:
100
,
child:
InkWell
(
onTap:
enabled
?
()
{
}
:
null
,
onHover:
(
bool
value
)
{
},
hoverColor:
const
Color
(
0xff00ff00
),
),
),
),
),
);
}
await
tester
.
pumpWidget
(
buildFrame
(
enabled:
true
));
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
);
await
gesture
.
addPointer
();
// Hover the enabled InkWell.
await
gesture
.
moveTo
(
tester
.
getCenter
(
find
.
byType
(
InkWell
)));
await
tester
.
pumpAndSettle
();
expect
(
find
.
byType
(
Material
),
paints
..
rect
(
color:
const
Color
(
0xff00ff00
),
rect:
const
Rect
.
fromLTRB
(
350.0
,
250.0
,
450.0
,
350.0
),
)
);
// Disable the hovered InkWell.
await
tester
.
pumpWidget
(
buildFrame
(
enabled:
false
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
byType
(
Material
),
paints
..
rect
(
color:
const
Color
(
0x0000ff00
),
rect:
const
Rect
.
fromLTRB
(
350.0
,
250.0
,
450.0
,
350.0
),
)
);
});
testWidgets
(
'Changing InkWell.enabled should not trigger TextButton setState()'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Changing InkWell.enabled should not trigger TextButton setState()'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
({
required
bool
enabled
})
{
Widget
buildFrame
({
required
bool
enabled
})
{
return
Material
(
return
Material
(
...
...
packages/flutter/test/material/list_tile_test.dart
View file @
ad7322dd
...
@@ -979,7 +979,7 @@ void main() {
...
@@ -979,7 +979,7 @@ void main() {
paints
paints
..
rect
()
..
rect
()
..
rect
(
..
rect
(
color:
Colors
.
orange
[
500
],
color:
Colors
.
orange
[
500
]
!.
withAlpha
(
0
)
,
rect:
const
Rect
.
fromLTRB
(
350.0
,
250.0
,
450.0
,
350.0
),
rect:
const
Rect
.
fromLTRB
(
350.0
,
250.0
,
450.0
,
350.0
),
)
)
..
rect
(
..
rect
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment