diff --git a/packages/flutter/lib/src/material/chip.dart b/packages/flutter/lib/src/material/chip.dart index 04e0bd7744c..71642ee3ce1 100644 --- a/packages/flutter/lib/src/material/chip.dart +++ b/packages/flutter/lib/src/material/chip.dart @@ -2488,7 +2488,7 @@ class _RenderChip extends RenderBox { @override double computeMaxIntrinsicWidth(double height) { - final double overallPadding = theme.padding.vertical + + final double overallPadding = theme.padding.horizontal + theme.labelPadding.horizontal; return overallPadding + _maxWidth(avatar, height) + diff --git a/packages/flutter/test/material/chip_test.dart b/packages/flutter/test/material/chip_test.dart index 9f7cfa340c8..ef47837f1f1 100644 --- a/packages/flutter/test/material/chip_test.dart +++ b/packages/flutter/test/material/chip_test.dart @@ -2916,6 +2916,18 @@ void main() { await tapGesture.up(); }); + + testWidgets('intrinsicHeight implementation meets constraints', (WidgetTester tester) async { + // Regression text for https://github.com/flutter/flutter/issues/49478. + await tester.pumpWidget(_wrapForChip( + child: const Chip( + label: Text('text'), + padding: EdgeInsets.symmetric(horizontal: 20), + ), + )); + + expect(tester.takeException(), isNull); + }); } class _MaterialStateOutlinedBorder extends StadiumBorder implements MaterialStateOutlinedBorder {