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
15cb1f84
Unverified
Commit
15cb1f84
authored
Apr 17, 2023
by
Taha Tesser
Committed by
GitHub
Apr 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Chip highlight color isn't drawn on top of the background color (#124673)
parent
7424f344
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
2 deletions
+52
-2
chip.dart
packages/flutter/lib/src/material/chip.dart
+2
-1
chip_test.dart
packages/flutter/test/material/chip_test.dart
+50
-1
No files found.
packages/flutter/lib/src/material/chip.dart
View file @
15cb1f84
...
@@ -14,6 +14,7 @@ import 'colors.dart';
...
@@ -14,6 +14,7 @@ import 'colors.dart';
import
'constants.dart'
;
import
'constants.dart'
;
import
'debug.dart'
;
import
'debug.dart'
;
import
'icons.dart'
;
import
'icons.dart'
;
import
'ink_decoration.dart'
;
import
'ink_well.dart'
;
import
'ink_well.dart'
;
import
'material.dart'
;
import
'material.dart'
;
import
'material_localizations.dart'
;
import
'material_localizations.dart'
;
...
@@ -1210,7 +1211,7 @@ class _RawChipState extends State<RawChip> with MaterialStateMixin, TickerProvid
...
@@ -1210,7 +1211,7 @@ class _RawChipState extends State<RawChip> with MaterialStateMixin, TickerProvid
child:
AnimatedBuilder
(
child:
AnimatedBuilder
(
animation:
Listenable
.
merge
(<
Listenable
>[
selectController
,
enableController
]),
animation:
Listenable
.
merge
(<
Listenable
>[
selectController
,
enableController
]),
builder:
(
BuildContext
context
,
Widget
?
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
Container
(
return
Ink
(
decoration:
ShapeDecoration
(
decoration:
ShapeDecoration
(
shape:
resolvedShape
,
shape:
resolvedShape
,
color:
_getBackgroundColor
(
theme
,
chipTheme
,
chipDefaults
),
color:
_getBackgroundColor
(
theme
,
chipTheme
,
chipDefaults
),
...
...
packages/flutter/test/material/chip_test.dart
View file @
15cb1f84
...
@@ -57,7 +57,7 @@ dynamic getRenderChip(WidgetTester tester) {
...
@@ -57,7 +57,7 @@ dynamic getRenderChip(WidgetTester tester) {
if
(!
tester
.
any
(
findRenderChipElement
()))
{
if
(!
tester
.
any
(
findRenderChipElement
()))
{
return
null
;
return
null
;
}
}
final
Element
element
=
tester
.
element
(
findRenderChipElement
());
final
Element
element
=
tester
.
element
(
findRenderChipElement
()
.
first
);
return
element
.
renderObject
;
return
element
.
renderObject
;
}
}
...
@@ -3284,6 +3284,55 @@ void main() {
...
@@ -3284,6 +3284,55 @@ void main() {
expect
(
tester
.
takeException
(),
isNull
);
expect
(
tester
.
takeException
(),
isNull
);
});
});
testWidgets
(
'Chip background color and shape are drawn on Ink'
,
(
WidgetTester
tester
)
async
{
const
Color
backgroundColor
=
Color
(
0xff00ff00
);
const
OutlinedBorder
shape
=
ContinuousRectangleBorder
();
await
tester
.
pumpWidget
(
wrapForChip
(
child:
const
RawChip
(
label:
Text
(
'text'
),
backgroundColor:
backgroundColor
,
shape:
shape
,
),
));
final
Ink
ink
=
tester
.
widget
(
find
.
descendant
(
of:
find
.
byType
(
RawChip
),
matching:
find
.
byType
(
Ink
),
));
final
ShapeDecoration
decoration
=
ink
.
decoration
!
as
ShapeDecoration
;
expect
(
decoration
.
color
,
backgroundColor
);
expect
(
decoration
.
shape
,
shape
);
});
testWidgets
(
'Chip highlight color is drawn on top of the backgroundColor'
,
(
WidgetTester
tester
)
async
{
final
FocusNode
focusNode
=
FocusNode
(
debugLabel:
'RawChip'
);
tester
.
binding
.
focusManager
.
highlightStrategy
=
FocusHighlightStrategy
.
alwaysTraditional
;
const
Color
backgroundColor
=
Color
(
0xff00ff00
);
await
tester
.
pumpWidget
(
wrapForChip
(
child:
RawChip
(
label:
const
Text
(
'text'
),
backgroundColor:
backgroundColor
,
autofocus:
true
,
focusNode:
focusNode
,
onPressed:
()
{},
),
));
await
tester
.
pumpAndSettle
();
expect
(
focusNode
.
hasPrimaryFocus
,
isTrue
);
expect
(
find
.
byType
(
Material
).
last
,
paints
// Background color is drawn first.
..
rrect
(
color:
backgroundColor
)
// Highlight color is drawn on top of the background color.
..
rect
(
color:
const
Color
(
0x1f000000
)),
);
});
}
}
class
_MaterialStateOutlinedBorder
extends
StadiumBorder
implements
MaterialStateOutlinedBorder
{
class
_MaterialStateOutlinedBorder
extends
StadiumBorder
implements
MaterialStateOutlinedBorder
{
...
...
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