From 56716f61a234ad63f5502a7cf9a0a905ef33218f Mon Sep 17 00:00:00 2001 From: David Martos Date: Wed, 9 Dec 2020 20:28:05 +0100 Subject: [PATCH] Chip theme label style is merged with the provided label style (#70687) --- packages/flutter/lib/src/material/chip.dart | 2 +- packages/flutter/test/material/chip_test.dart | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/chip.dart b/packages/flutter/lib/src/material/chip.dart index 630daeafaf..e083e9f916 100644 --- a/packages/flutter/lib/src/material/chip.dart +++ b/packages/flutter/lib/src/material/chip.dart @@ -1929,7 +1929,7 @@ class _RawChipState extends State with TickerProviderStateMixin(effectiveLabelStyle.color, _states); final TextStyle resolvedLabelStyle = effectiveLabelStyle.copyWith(color: resolvedLabelColor); final EdgeInsetsGeometry labelPadding = widget.labelPadding ?? chipTheme.labelPadding ?? _defaultLabelPadding; diff --git a/packages/flutter/test/material/chip_test.dart b/packages/flutter/test/material/chip_test.dart index ef47837f1f..b10320a94c 100644 --- a/packages/flutter/test/material/chip_test.dart +++ b/packages/flutter/test/material/chip_test.dart @@ -1440,6 +1440,32 @@ void main() { expect(materialBox, paints..path(color: chipTheme.disabledColor)); }); + testWidgets('Chip merges ChipThemeData label style with the provided label style', (WidgetTester tester) async { + // The font family should be preserved even if the chip overrides some label style properties + final ThemeData theme = ThemeData( + fontFamily: 'MyFont' + ); + + Widget buildChip() { + return _wrapForChip( + textDirection: TextDirection.ltr, + child: Theme( + data: theme, + child: const Chip( + label: Text('Label'), + labelStyle: TextStyle(fontWeight: FontWeight.w200), + ), + ), + ); + } + + await tester.pumpWidget(buildChip()); + + final TextStyle labelStyle = getLabelStyle(tester).style; + expect(labelStyle.fontFamily, 'MyFont'); + expect(labelStyle.fontWeight, FontWeight.w200); + }); + testWidgets('Chip size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async { final Key key1 = UniqueKey(); await tester.pumpWidget(