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
0c7bc2f9
Unverified
Commit
0c7bc2f9
authored
Apr 20, 2023
by
9oya
Committed by
GitHub
Apr 20, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement CheckmarkableChipAttributes on ChoiceChip (#124743)
parent
d85e2fb8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
1 deletion
+42
-1
chip.dart
packages/flutter/lib/src/material/chip.dart
+2
-0
choice_chip.dart
packages/flutter/lib/src/material/choice_chip.dart
+9
-1
choice_chip_test.dart
packages/flutter/test/material/choice_chip_test.dart
+31
-0
No files found.
packages/flutter/lib/src/material/chip.dart
View file @
0c7bc2f9
...
...
@@ -275,6 +275,8 @@ abstract interface class DeletableChipAttributes {
/// * [InputChip], a chip that represents a complex piece of information, such
/// as an entity (person, place, or thing) or conversational text, in a
/// compact form.
/// * [ChoiceChip], allows a single selection from a set of options. Choice
/// chips contain related descriptive text or categories.
/// * [FilterChip], uses tags or descriptive words as a way to filter content.
/// * <https://material.io/design/components/chips.html>
abstract
interface
class
CheckmarkableChipAttributes
{
...
...
packages/flutter/lib/src/material/choice_chip.dart
View file @
0c7bc2f9
...
...
@@ -52,6 +52,7 @@ class ChoiceChip extends StatelessWidget
implements
ChipAttributes
,
SelectableChipAttributes
,
CheckmarkableChipAttributes
,
DisabledChipAttributes
{
/// Create a chip that acts like a radio button.
///
...
...
@@ -84,6 +85,8 @@ class ChoiceChip extends StatelessWidget
this
.
surfaceTintColor
,
this
.
iconTheme
,
this
.
selectedShadowColor
,
this
.
showCheckmark
,
this
.
checkmarkColor
,
this
.
avatarBorder
=
const
CircleBorder
(),
})
:
assert
(
pressElevation
==
null
||
pressElevation
>=
0.0
),
assert
(
elevation
==
null
||
elevation
>=
0.0
);
...
...
@@ -135,6 +138,10 @@ class ChoiceChip extends StatelessWidget
@override
final
Color
?
selectedShadowColor
;
@override
final
bool
?
showCheckmark
;
@override
final
Color
?
checkmarkColor
;
@override
final
ShapeBorder
avatarBorder
;
@override
final
IconThemeData
?
iconTheme
;
...
...
@@ -158,7 +165,8 @@ class ChoiceChip extends StatelessWidget
onSelected:
onSelected
,
pressElevation:
pressElevation
,
selected:
selected
,
showCheckmark:
Theme
.
of
(
context
).
useMaterial3
,
showCheckmark:
showCheckmark
??
chipTheme
.
showCheckmark
??
Theme
.
of
(
context
).
useMaterial3
,
checkmarkColor:
checkmarkColor
,
tooltip:
tooltip
,
side:
side
,
shape:
shape
,
...
...
packages/flutter/test/material/choice_chip_test.dart
View file @
0c7bc2f9
...
...
@@ -132,4 +132,35 @@ void main() {
final
RawChip
rawChip
=
tester
.
widget
(
find
.
byType
(
RawChip
));
expect
(
rawChip
.
iconTheme
,
iconTheme
);
});
testWidgets
(
'ChoiceChip passes showCheckmark from ChipTheme to RawChip'
,
(
WidgetTester
tester
)
async
{
const
bool
showCheckmark
=
false
;
await
tester
.
pumpWidget
(
wrapForChip
(
child:
const
ChipTheme
(
data:
ChipThemeData
(
showCheckmark:
showCheckmark
,
),
child:
ChoiceChip
(
label:
Text
(
'Test'
),
selected:
true
,
),
)));
final
RawChip
rawChip
=
tester
.
widget
(
find
.
byType
(
RawChip
));
expect
(
rawChip
.
showCheckmark
,
showCheckmark
);
});
testWidgets
(
'ChoiceChip passes checkmark properties to RawChip'
,
(
WidgetTester
tester
)
async
{
const
bool
showCheckmark
=
false
;
const
Color
checkmarkColor
=
Color
(
0xff0000ff
);
await
tester
.
pumpWidget
(
wrapForChip
(
child:
const
ChoiceChip
(
label:
Text
(
'Test'
),
selected:
true
,
showCheckmark:
showCheckmark
,
checkmarkColor:
checkmarkColor
,
)));
final
RawChip
rawChip
=
tester
.
widget
(
find
.
byType
(
RawChip
));
expect
(
rawChip
.
showCheckmark
,
showCheckmark
);
expect
(
rawChip
.
checkmarkColor
,
checkmarkColor
);
});
}
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