Skip to content

Commit

Permalink
Remove chip tooltip deprecations (flutter#134486)
Browse files Browse the repository at this point in the history
Part of flutter#133171

These deprecations were introduced in flutter#96174
The replacement is to use `deleteButtonTooltipMessage`.
This migration is supported by dart fix. â�
  • Loading branch information
Piinks authored Sep 12, 2023
1 parent cba7daf commit 4e7a07a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 75 deletions.
38 changes: 2 additions & 36 deletions packages/flutter/lib/src/material/chip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,6 @@ abstract interface class DeletableChipAttributes {
/// If null, the default [MaterialLocalizations.deleteButtonTooltip] will be
/// used.
String? get deleteButtonTooltipMessage;

/// Whether to use a tooltip on the chip's delete button showing the
/// [deleteButtonTooltipMessage].
///
/// Defaults to true.
@Deprecated(
'Migrate to deleteButtonTooltipMessage. '
'This feature was deprecated after v2.10.0-0.3.pre.'
)
bool get useDeleteButtonTooltip;
}

/// An interface for Material Design chips that can have check marks.
Expand Down Expand Up @@ -597,11 +587,6 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
this.shadowColor,
this.surfaceTintColor,
this.iconTheme,
@Deprecated(
'Migrate to deleteButtonTooltipMessage. '
'This feature was deprecated after v2.10.0-0.3.pre.'
)
this.useDeleteButtonTooltip = true,
}) : assert(elevation == null || elevation >= 0.0);

@override
Expand Down Expand Up @@ -648,12 +633,6 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
final Color? surfaceTintColor;
@override
final IconThemeData? iconTheme;
@override
@Deprecated(
'Migrate to deleteButtonTooltipMessage. '
'This feature was deprecated after v2.10.0-0.3.pre.'
)
final bool useDeleteButtonTooltip;

@override
Widget build(BuildContext context) {
Expand All @@ -666,7 +645,6 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
deleteIcon: deleteIcon,
onDeleted: onDeleted,
deleteIconColor: deleteIconColor,
useDeleteButtonTooltip: useDeleteButtonTooltip,
deleteButtonTooltipMessage: deleteButtonTooltipMessage,
tapEnabled: false,
side: side,
Expand Down Expand Up @@ -771,11 +749,6 @@ class RawChip extends StatefulWidget
this.showCheckmark,
this.checkmarkColor,
this.avatarBorder = const CircleBorder(),
@Deprecated(
'Migrate to deleteButtonTooltipMessage. '
'This feature was deprecated after v2.10.0-0.3.pre.'
)
this.useDeleteButtonTooltip = true,
}) : assert(pressElevation == null || pressElevation >= 0.0),
assert(elevation == null || elevation >= 0.0),
deleteIcon = deleteIcon ?? _kDefaultDeleteIcon;
Expand Down Expand Up @@ -855,12 +828,6 @@ class RawChip extends StatefulWidget
final Color? checkmarkColor;
@override
final ShapeBorder avatarBorder;
@override
@Deprecated(
'Migrate to deleteButtonTooltipMessage. '
'This feature was deprecated after v2.10.0-0.3.pre.'
)
final bool useDeleteButtonTooltip;

/// If set, this indicates that the chip should be disabled if all of the
/// tap callbacks ([onSelected], [onPressed]) are null.
Expand Down Expand Up @@ -1159,9 +1126,8 @@ class _RawChipState extends State<RawChip> with MaterialStateMixin, TickerProvid
container: true,
button: true,
child: _wrapWithTooltip(
tooltip: widget.useDeleteButtonTooltip
? widget.deleteButtonTooltipMessage ?? MaterialLocalizations.of(context).deleteButtonTooltip
: null,
tooltip: widget.deleteButtonTooltipMessage
?? MaterialLocalizations.of(context).deleteButtonTooltip,
enabled: widget.onDeleted != null,
child: InkWell(
// Radius should be slightly less than the full size of the chip.
Expand Down
12 changes: 0 additions & 12 deletions packages/flutter/lib/src/material/input_chip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ class InputChip extends StatelessWidget
this.showCheckmark,
this.checkmarkColor,
this.avatarBorder = const CircleBorder(),
@Deprecated(
'Migrate to deleteButtonTooltipMessage. '
'This feature was deprecated after v2.10.0-0.3.pre.'
)
this.useDeleteButtonTooltip = true,
}) : assert(pressElevation == null || pressElevation >= 0.0),
assert(elevation == null || elevation >= 0.0);

Expand Down Expand Up @@ -199,12 +194,6 @@ class InputChip extends StatelessWidget
final ShapeBorder avatarBorder;
@override
final IconThemeData? iconTheme;
@override
@Deprecated(
'Migrate to deleteButtonTooltipMessage. '
'This feature was deprecated after v2.10.0-0.3.pre.'
)
final bool useDeleteButtonTooltip;

@override
Widget build(BuildContext context) {
Expand All @@ -223,7 +212,6 @@ class InputChip extends StatelessWidget
deleteIcon: resolvedDeleteIcon,
onDeleted: onDeleted,
deleteIconColor: deleteIconColor,
useDeleteButtonTooltip: useDeleteButtonTooltip,
deleteButtonTooltipMessage: deleteButtonTooltipMessage,
onSelected: onSelected,
onPressed: onPressed,
Expand Down
27 changes: 0 additions & 27 deletions packages/flutter/test/material/chip_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ Widget chipWithOptionalDeleteButton({
Key? labelKey,
required bool deletable,
TextDirection textDirection = TextDirection.ltr,
bool useDeleteButtonTooltip = true,
String? chipTooltip,
String? deleteButtonTooltipMessage,
VoidCallback? onPressed = doNothing,
Expand All @@ -154,7 +153,6 @@ Widget chipWithOptionalDeleteButton({
onPressed: onPressed,
onDeleted: deletable ? doNothing : null,
deleteIcon: Icon(Icons.close, key: deleteButtonKey),
useDeleteButtonTooltip: useDeleteButtonTooltip,
deleteButtonTooltipMessage: deleteButtonTooltipMessage,
label: Text(
deletable
Expand Down Expand Up @@ -3204,31 +3202,6 @@ void main() {
expect(box.size, equals(const Size(128, 24.0 + 16.0)));
});

testWidgetsWithLeakTracking('Chip delete button tooltip can be disabled using useDeleteButtonTooltip', (WidgetTester tester) async {
await tester.pumpWidget(
chipWithOptionalDeleteButton(
deletable: true,
useDeleteButtonTooltip: 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).first);
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 delete button tooltip
expect(findTooltipContainer('Delete'), findsNothing);

await tapGesture.up();
});

testWidgetsWithLeakTracking('Chip delete button tooltip is disabled if deleteButtonTooltipMessage is empty', (WidgetTester tester) async {
final UniqueKey deleteButtonKey = UniqueKey();
await tester.pumpWidget(
Expand Down

0 comments on commit 4e7a07a

Please sign in to comment.