Unverified Commit b7d22122 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Simplify Chip slightly (#47254)

parent 0f8c0da0
...@@ -1851,10 +1851,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip ...@@ -1851,10 +1851,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
animation: Listenable.merge(<Listenable>[selectController, enableController]), animation: Listenable.merge(<Listenable>[selectController, enableController]),
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget child) {
return Container( return Container(
decoration: ShapeDecoration( color: getBackgroundColor(chipTheme),
shape: shape,
color: getBackgroundColor(chipTheme),
),
child: child, child: child,
); );
}, },
......
...@@ -178,13 +178,7 @@ Future<void> _pumpCheckmarkChip( ...@@ -178,13 +178,7 @@ Future<void> _pumpCheckmarkChip(
void _expectCheckmarkColor(Finder finder, Color color) { void _expectCheckmarkColor(Finder finder, Color color) {
expect( expect(
finder, finder,
paints paints..path(color: color)
// The first path that is painted is the selection overlay. We do not care
// how it is painted but it has to be added it to this pattern so that the
// check mark can be checked next.
..path()
// The second path that is painted is the check mark.
..path(color: color),
); );
} }
...@@ -1435,7 +1429,7 @@ void main() { ...@@ -1435,7 +1429,7 @@ void main() {
), ),
); );
expect(materialBox, paints..path(color: chipTheme.disabledColor)); expect(materialBox, paints..rect(color: chipTheme.disabledColor));
}); });
testWidgets('Chip size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async { testWidgets('Chip size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
...@@ -1535,13 +1529,13 @@ void main() { ...@@ -1535,13 +1529,13 @@ void main() {
DefaultTextStyle labelStyle = getLabelStyle(tester); DefaultTextStyle labelStyle = getLabelStyle(tester);
// Check default theme for enabled widget. // Check default theme for enabled widget.
expect(materialBox, paints..path(color: defaultChipTheme.backgroundColor)); expect(materialBox, paints..rect(color: defaultChipTheme.backgroundColor));
expect(iconData.color, equals(const Color(0xde000000))); expect(iconData.color, equals(const Color(0xde000000)));
expect(labelStyle.style.color, equals(Colors.black.withAlpha(0xde))); expect(labelStyle.style.color, equals(Colors.black.withAlpha(0xde)));
await tester.tap(find.byType(RawChip)); await tester.tap(find.byType(RawChip));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
materialBox = getMaterialBox(tester); materialBox = getMaterialBox(tester);
expect(materialBox, paints..path(color: defaultChipTheme.selectedColor)); expect(materialBox, paints..rect(color: defaultChipTheme.selectedColor));
await tester.tap(find.byType(RawChip)); await tester.tap(find.byType(RawChip));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -1550,7 +1544,7 @@ void main() { ...@@ -1550,7 +1544,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
materialBox = getMaterialBox(tester); materialBox = getMaterialBox(tester);
labelStyle = getLabelStyle(tester); labelStyle = getLabelStyle(tester);
expect(materialBox, paints..path(color: defaultChipTheme.disabledColor)); expect(materialBox, paints..rect(color: defaultChipTheme.disabledColor));
expect(labelStyle.style.color, equals(Colors.black.withAlpha(0xde))); expect(labelStyle.style.color, equals(Colors.black.withAlpha(0xde)));
// Apply a custom theme. // Apply a custom theme.
...@@ -1572,13 +1566,13 @@ void main() { ...@@ -1572,13 +1566,13 @@ void main() {
labelStyle = getLabelStyle(tester); labelStyle = getLabelStyle(tester);
// Check custom theme for enabled widget. // Check custom theme for enabled widget.
expect(materialBox, paints..path(color: customTheme.backgroundColor)); expect(materialBox, paints..rect(color: customTheme.backgroundColor));
expect(iconData.color, equals(customTheme.deleteIconColor)); expect(iconData.color, equals(customTheme.deleteIconColor));
expect(labelStyle.style.color, equals(Colors.black.withAlpha(0xde))); expect(labelStyle.style.color, equals(Colors.black.withAlpha(0xde)));
await tester.tap(find.byType(RawChip)); await tester.tap(find.byType(RawChip));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
materialBox = getMaterialBox(tester); materialBox = getMaterialBox(tester);
expect(materialBox, paints..path(color: customTheme.selectedColor)); expect(materialBox, paints..rect(color: customTheme.selectedColor));
await tester.tap(find.byType(RawChip)); await tester.tap(find.byType(RawChip));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -1592,7 +1586,7 @@ void main() { ...@@ -1592,7 +1586,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
materialBox = getMaterialBox(tester); materialBox = getMaterialBox(tester);
labelStyle = getLabelStyle(tester); labelStyle = getLabelStyle(tester);
expect(materialBox, paints..path(color: customTheme.disabledColor)); expect(materialBox, paints..rect(color: customTheme.disabledColor));
expect(labelStyle.style.color, equals(Colors.black.withAlpha(0xde))); expect(labelStyle.style.color, equals(Colors.black.withAlpha(0xde)));
}); });
......
...@@ -107,7 +107,7 @@ void main() { ...@@ -107,7 +107,7 @@ void main() {
final RenderBox materialBox = getMaterialBox(tester); final RenderBox materialBox = getMaterialBox(tester);
expect(materialBox, paints..path(color: chipTheme.backgroundColor)); expect(materialBox, paints..rect(color: chipTheme.backgroundColor));
}); });
testWidgets('Chip overrides ThemeData theme if ChipTheme present', (WidgetTester tester) async { testWidgets('Chip overrides ThemeData theme if ChipTheme present', (WidgetTester tester) async {
...@@ -161,7 +161,7 @@ void main() { ...@@ -161,7 +161,7 @@ void main() {
final RenderBox materialBox = getMaterialBox(tester); final RenderBox materialBox = getMaterialBox(tester);
final Material material = getMaterial(tester); final Material material = getMaterial(tester);
expect(materialBox, paints..path(color: Color(customTheme.backgroundColor.value))); expect(materialBox, paints..rect(color: Color(customTheme.backgroundColor.value)));
expect(material.elevation, customTheme.elevation); expect(material.elevation, customTheme.elevation);
expect(material.shadowColor, customTheme.shadowColor); expect(material.shadowColor, customTheme.shadowColor);
}, skip: isBrowser); }, skip: isBrowser);
......
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