Unverified Commit 56716f61 authored by David Martos's avatar David Martos Committed by GitHub

Chip theme label style is merged with the provided label style (#70687)

parent d553aa06
......@@ -1929,7 +1929,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
final Color? checkmarkColor = widget.checkmarkColor ?? chipTheme.checkmarkColor;
final bool showCheckmark = widget.showCheckmark ?? chipTheme.showCheckmark ?? true;
final TextStyle effectiveLabelStyle = widget.labelStyle ?? chipTheme.labelStyle;
final TextStyle effectiveLabelStyle = chipTheme.labelStyle.merge(widget.labelStyle);
final Color? resolvedLabelColor = MaterialStateProperty.resolveAs<Color?>(effectiveLabelStyle.color, _states);
final TextStyle resolvedLabelStyle = effectiveLabelStyle.copyWith(color: resolvedLabelColor);
final EdgeInsetsGeometry labelPadding = widget.labelPadding ?? chipTheme.labelPadding ?? _defaultLabelPadding;
......
......@@ -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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment