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
7d4497a1
Unverified
Commit
7d4497a1
authored
Jan 11, 2022
by
Hans Muller
Committed by
GitHub
Jan 11, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InkWell.overlayColor is now resolved against MaterialState.pressed (#96435)
parent
9c5b3907
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
8 deletions
+45
-8
ink_well.dart
packages/flutter/lib/src/material/ink_well.dart
+11
-8
ink_well_test.dart
packages/flutter/test/material/ink_well_test.dart
+34
-0
No files found.
packages/flutter/lib/src/material/ink_well.dart
View file @
7d4497a1
...
...
@@ -483,11 +483,12 @@ class InkResponse extends StatelessWidget {
/// Defines the ink response focus, hover, and splash colors.
///
/// This default null property can be used as an alternative to
/// [focusColor], [hoverColor], and [splashColor]. If non-null,
/// it is resolved against one of [MaterialState.focused],
/// [MaterialState.hovered], and [MaterialState.pressed]. It's
/// convenient to use when the parent widget can pass along its own
/// MaterialStateProperty value for the overlay color.
/// [focusColor], [hoverColor], [highlightColor], and
/// [splashColor]. If non-null, it is resolved against one of
/// [MaterialState.focused], [MaterialState.hovered], and
/// [MaterialState.pressed]. It's convenient to use when the parent
/// widget can pass along its own MaterialStateProperty value for
/// the overlay color.
///
/// [MaterialState.pressed] triggers a ripple (an ink splash), per
/// the current Material Design spec. The [overlayColor] doesn't map
...
...
@@ -799,19 +800,21 @@ class _InkResponseState extends State<_InkResponseStateWidget>
bool
get
wantKeepAlive
=>
highlightsExist
||
(
_splashes
!=
null
&&
_splashes
!.
isNotEmpty
);
Color
getHighlightColorForType
(
_HighlightType
type
)
{
const
Set
<
MaterialState
>
pressed
=
<
MaterialState
>{
MaterialState
.
pressed
};
const
Set
<
MaterialState
>
focused
=
<
MaterialState
>{
MaterialState
.
focused
};
const
Set
<
MaterialState
>
hovered
=
<
MaterialState
>{
MaterialState
.
hovered
};
final
ThemeData
theme
=
Theme
.
of
(
context
);
switch
(
type
)
{
// The pressed state triggers a ripple (ink splash), per the current
// Material Design spec. A separate highlight is no longer used.
// See https://material.io/design/interaction/states.html#pressed
case
_HighlightType
.
pressed
:
return
widget
.
highlightColor
??
Theme
.
of
(
context
)
.
highlightColor
;
return
widget
.
overlayColor
?.
resolve
(
pressed
)
??
widget
.
highlightColor
??
theme
.
highlightColor
;
case
_HighlightType
.
focus
:
return
widget
.
overlayColor
?.
resolve
(
focused
)
??
widget
.
focusColor
??
Theme
.
of
(
context
)
.
focusColor
;
return
widget
.
overlayColor
?.
resolve
(
focused
)
??
widget
.
focusColor
??
theme
.
focusColor
;
case
_HighlightType
.
hover
:
return
widget
.
overlayColor
?.
resolve
(
hovered
)
??
widget
.
hoverColor
??
Theme
.
of
(
context
)
.
hoverColor
;
return
widget
.
overlayColor
?.
resolve
(
hovered
)
??
widget
.
hoverColor
??
theme
.
hoverColor
;
}
}
...
...
packages/flutter/test/material/ink_well_test.dart
View file @
7d4497a1
...
...
@@ -292,6 +292,40 @@ void main() {
);
});
testWidgets
(
'ink well changes color on pressed with overlayColor'
,
(
WidgetTester
tester
)
async
{
const
Color
pressedColor
=
Color
(
0xffdd00ff
);
await
tester
.
pumpWidget
(
Material
(
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Container
(
alignment:
Alignment
.
topLeft
,
child:
SizedBox
(
width:
100
,
height:
100
,
child:
InkWell
(
splashFactory:
NoSplash
.
splashFactory
,
overlayColor:
MaterialStateProperty
.
resolveWith
<
Color
>((
Set
<
MaterialState
>
states
)
{
if
(
states
.
contains
(
MaterialState
.
pressed
))
{
return
pressedColor
;
}
return
const
Color
(
0xffbadbad
);
// Shouldn't happen.
}),
onTap:
()
{
},
),
),
),
),
));
await
tester
.
pumpAndSettle
();
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getRect
(
find
.
byType
(
InkWell
)).
center
);
final
RenderObject
inkFeatures
=
tester
.
allRenderObjects
.
firstWhere
((
RenderObject
object
)
=>
object
.
runtimeType
.
toString
()
==
'_RenderInkFeatures'
);
expect
(
inkFeatures
,
paints
..
rect
(
rect:
const
Rect
.
fromLTRB
(
0
,
0
,
100
,
100
),
color:
pressedColor
.
withAlpha
(
0
)));
await
tester
.
pumpAndSettle
();
// Let the press highlight animation finish.
expect
(
inkFeatures
,
paints
..
rect
(
rect:
const
Rect
.
fromLTRB
(
0
,
0
,
100
,
100
),
color:
pressedColor
));
await
gesture
.
up
();
});
testWidgets
(
'ink response splashColor matches splashColor parameter'
,
(
WidgetTester
tester
)
async
{
FocusManager
.
instance
.
highlightStrategy
=
FocusHighlightStrategy
.
alwaysTouch
;
final
FocusNode
focusNode
=
FocusNode
(
debugLabel:
'Ink Focus'
);
...
...
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