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
f03caeaf
Unverified
Commit
f03caeaf
authored
Oct 28, 2020
by
Anurag Roy
Committed by
GitHub
Oct 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add useDeleteButtonTooltip property for Chip (#68237)
parent
7b86be22
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
0 deletions
+53
-0
AUTHORS
AUTHORS
+1
-0
chip.dart
packages/flutter/lib/src/material/chip.dart
+25
-0
chip_test.dart
packages/flutter/test/material/chip_test.dart
+27
-0
No files found.
AUTHORS
View file @
f03caeaf
...
...
@@ -69,3 +69,4 @@ Terrence Addison Tandijono(flotilla) <terrenceaddison32@gmail.com>
YeungKC <flutter@yeungkc.com>
Nobuhiro Tabuki <japanese.around30@gmail.com>
nt4f04uNd <nt4f04und@gmail.com>
Anurag Roy <anuragr9847@gmail.com>
packages/flutter/lib/src/material/chip.dart
View file @
f03caeaf
...
...
@@ -258,7 +258,15 @@ abstract class DeletableChipAttributes {
/// [IconThemeData.color].
Color
?
get
deleteIconColor
;
/// Whether to use a tooltip on the chip's delete button showing the
/// [deleteButtonTooltipMessage].
///
/// Must not be null. Defaults to true.
bool
get
useDeleteButtonTooltip
;
/// The message to be used for the chip's delete button tooltip.
///
/// This will be shown only if [useDeleteButtonTooltip] is true.
String
?
get
deleteButtonTooltipMessage
;
}
...
...
@@ -566,6 +574,7 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
this
.
deleteIcon
,
this
.
onDeleted
,
this
.
deleteIconColor
,
this
.
useDeleteButtonTooltip
=
true
,
this
.
deleteButtonTooltipMessage
,
this
.
shape
,
this
.
clipBehavior
=
Clip
.
none
,
...
...
@@ -581,6 +590,7 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
assert
(
autofocus
!=
null
),
assert
(
clipBehavior
!=
null
),
assert
(
elevation
==
null
||
elevation
>=
0.0
),
assert
(
useDeleteButtonTooltip
!=
null
),
super
(
key:
key
);
@override
...
...
@@ -612,6 +622,8 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
@override
final
Color
?
deleteIconColor
;
@override
final
bool
useDeleteButtonTooltip
;
@override
final
String
?
deleteButtonTooltipMessage
;
@override
final
MaterialTapTargetSize
?
materialTapTargetSize
;
...
...
@@ -631,6 +643,7 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
deleteIcon:
deleteIcon
,
onDeleted:
onDeleted
,
deleteIconColor:
deleteIconColor
,
useDeleteButtonTooltip:
useDeleteButtonTooltip
,
deleteButtonTooltipMessage:
deleteButtonTooltipMessage
,
tapEnabled:
false
,
shape:
shape
,
...
...
@@ -722,6 +735,7 @@ class InputChip extends StatelessWidget
this
.
deleteIcon
,
this
.
onDeleted
,
this
.
deleteIconColor
,
this
.
useDeleteButtonTooltip
=
true
,
this
.
deleteButtonTooltipMessage
,
this
.
onPressed
,
this
.
pressElevation
,
...
...
@@ -749,6 +763,7 @@ class InputChip extends StatelessWidget
assert
(
autofocus
!=
null
),
assert
(
pressElevation
==
null
||
pressElevation
>=
0.0
),
assert
(
elevation
==
null
||
elevation
>=
0.0
),
assert
(
useDeleteButtonTooltip
!=
null
),
super
(
key:
key
);
@override
...
...
@@ -772,6 +787,8 @@ class InputChip extends StatelessWidget
@override
final
Color
?
deleteIconColor
;
@override
final
bool
useDeleteButtonTooltip
;
@override
final
String
?
deleteButtonTooltipMessage
;
@override
final
VoidCallback
?
onPressed
;
...
...
@@ -823,6 +840,7 @@ class InputChip extends StatelessWidget
deleteIcon:
deleteIcon
,
onDeleted:
onDeleted
,
deleteIconColor:
deleteIconColor
,
useDeleteButtonTooltip:
useDeleteButtonTooltip
,
deleteButtonTooltipMessage:
deleteButtonTooltipMessage
,
onSelected:
onSelected
,
onPressed:
onPressed
,
...
...
@@ -1448,6 +1466,7 @@ class RawChip extends StatefulWidget
Widget
?
deleteIcon
,
this
.
onDeleted
,
this
.
deleteIconColor
,
this
.
useDeleteButtonTooltip
=
true
,
this
.
deleteButtonTooltipMessage
,
this
.
onPressed
,
this
.
onSelected
,
...
...
@@ -1477,6 +1496,7 @@ class RawChip extends StatefulWidget
assert
(
autofocus
!=
null
),
assert
(
pressElevation
==
null
||
pressElevation
>=
0.0
),
assert
(
elevation
==
null
||
elevation
>=
0.0
),
assert
(
useDeleteButtonTooltip
!=
null
),
deleteIcon
=
deleteIcon
??
_kDefaultDeleteIcon
,
super
(
key:
key
);
...
...
@@ -1495,6 +1515,8 @@ class RawChip extends StatefulWidget
@override
final
Color
?
deleteIconColor
;
@override
final
bool
useDeleteButtonTooltip
;
@override
final
String
?
deleteButtonTooltipMessage
;
@override
final
ValueChanged
<
bool
>?
onSelected
;
...
...
@@ -1767,6 +1789,9 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
}
Widget
?
_wrapWithTooltip
(
String
?
tooltip
,
VoidCallback
?
callback
,
Widget
?
child
)
{
if
(!
widget
.
useDeleteButtonTooltip
){
return
child
;
}
if
(
child
==
null
||
callback
==
null
||
tooltip
==
null
)
{
return
child
;
}
...
...
packages/flutter/test/material/chip_test.dart
View file @
f03caeaf
...
...
@@ -193,6 +193,7 @@ Widget _chipWithOptionalDeleteButton({
UniqueKey
?
labelKey
,
required
bool
deletable
,
TextDirection
textDirection
=
TextDirection
.
ltr
,
bool
hasDeleteButtonTooltip
=
true
,
}){
return
_wrapForChip
(
textDirection:
textDirection
,
...
...
@@ -202,6 +203,7 @@ Widget _chipWithOptionalDeleteButton({
onPressed:
()
{},
onDeleted:
deletable
?
()
{}
:
null
,
deleteIcon:
Icon
(
Icons
.
close
,
key:
deleteButtonKey
),
useDeleteButtonTooltip:
hasDeleteButtonTooltip
,
label:
Text
(
deletable
?
'Chip with Delete Button'
...
...
@@ -2679,4 +2681,29 @@ void main() {
const
Color
(
0xffff0000
),
);
});
testWidgets
(
'Chip delete button tooltip can be disabled'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_chipWithOptionalDeleteButton
(
deletable:
true
,
hasDeleteButtonTooltip:
false
,
)
);
// Tap at the delete icon of the chip, which is at the right
// side of the chip
final
Offset
topRightOfInkwell
=
tester
.
getTopLeft
(
find
.
byType
(
InkWell
));
final
Offset
tapLocationOfDeleteButton
=
topRightOfInkwell
+
const
Offset
(
8
,
8
);
final
TestGesture
tapGesture
=
await
tester
.
startGesture
(
tapLocationOfDeleteButton
);
await
tester
.
pump
();
// Wait for some more time while pressing and holding the delete button
await
tester
.
pumpAndSettle
();
// There should be no tooltip
expect
(
findTooltipContainer
(
'Delete'
),
findsNothing
);
await
tapGesture
.
up
();
});
}
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