From 588275e179379c957c4b7acf5cea1d2d1f2d6ce0 Mon Sep 17 00:00:00 2001 From: Per Classon Date: Wed, 23 Oct 2019 17:55:46 -0700 Subject: [PATCH] [Chip] Make sure InkResponse is in the foreground on delete for chips with background color (#41463) * Make sure InkResponse is visible on delete for chips with background color set * Override computeDistanceToActualBaseline in layout builder --- packages/flutter/lib/src/material/chip.dart | 3 +- .../lib/src/widgets/layout_builder.dart | 5 +++ packages/flutter/test/material/chip_test.dart | 29 +++++++++++++++ .../test/widgets/layout_builder_test.dart | 36 +++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/chip.dart b/packages/flutter/lib/src/material/chip.dart index 0fd49b8f39..e682ed0c4c 100644 --- a/packages/flutter/lib/src/material/chip.dart +++ b/packages/flutter/lib/src/material/chip.dart @@ -15,6 +15,7 @@ import 'constants.dart'; import 'debug.dart'; import 'feedback.dart'; import 'icons.dart'; +import 'ink_decoration.dart'; import 'ink_well.dart'; import 'material.dart'; import 'material_localizations.dart'; @@ -1813,7 +1814,7 @@ class _RawChipState extends State with TickerProviderStateMixin[selectController, enableController]), builder: (BuildContext context, Widget child) { - return Container( + return Ink( decoration: ShapeDecoration( shape: shape, color: getBackgroundColor(chipTheme), diff --git a/packages/flutter/lib/src/widgets/layout_builder.dart b/packages/flutter/lib/src/widgets/layout_builder.dart index 4a6c83b6e9..e9e8c5da42 100644 --- a/packages/flutter/lib/src/widgets/layout_builder.dart +++ b/packages/flutter/lib/src/widgets/layout_builder.dart @@ -235,6 +235,11 @@ class _RenderLayoutBuilder extends RenderBox with RenderObjectWithChildMixin [0, 0, 0]); }); + + testWidgets('LayoutBuilder calculates baseline from child', (WidgetTester tester) async { + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: Row( + crossAxisAlignment: CrossAxisAlignment.baseline, + textBaseline: TextBaseline.alphabetic, + children: [ + LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + return const Text('First', style: TextStyle(fontSize: 10)); + }, + ), + LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + return const Text('Second', style: TextStyle(fontSize: 30)); + }, + ), + ], + ), + ), + ); + + // The Ahem font extends 0.2 * fontSize below the baseline. + // So the two row elements line up like this: + // + // First Second + // ------------- baseline + // 2 6 space below the baseline = 0.2 * fontSize + // ------------- widget text dy values + + final double firstTextDy = tester.getBottomLeft(find.text('First')).dy; + final double secondTextDy = tester.getBottomLeft(find.text('Second')).dy; + expect(firstTextDy, closeTo(secondTextDy - 4.0, 0.001)); + }, skip: isBrowser); }