Unverified Commit ba489607 authored by Darren Austin's avatar Darren Austin Committed by GitHub

Fixed an issue with FilterChip's changing size when selected due to border size. (#111916)

parent 7f6c111c
......@@ -57,7 +57,7 @@ class _${blockName}DefaultsM3 extends ChipThemeData {
? isEnabled
? ${border('$tokenGroup$variant.unselected.outline')}
: ${border('$tokenGroup$variant.disabled.unselected.outline')}
: null;
: const BorderSide(color: Colors.transparent);
@override
IconThemeData? get iconTheme => IconThemeData(
......
......@@ -7,6 +7,7 @@ import 'package:flutter/widgets.dart';
import 'chip.dart';
import 'chip_theme.dart';
import 'colors.dart';
import 'debug.dart';
import 'theme.dart';
import 'theme_data.dart';
......@@ -236,7 +237,7 @@ class _ChoiceChipDefaultsM3 extends ChipThemeData {
? isEnabled
? BorderSide(color: Theme.of(context).colorScheme.outline)
: BorderSide(color: Theme.of(context).colorScheme.onSurface.withOpacity(0.12))
: null;
: const BorderSide(color: Colors.transparent);
@override
IconThemeData? get iconTheme => IconThemeData(
......
......@@ -7,6 +7,7 @@ import 'package:flutter/widgets.dart';
import 'chip.dart';
import 'chip_theme.dart';
import 'colors.dart';
import 'debug.dart';
import 'theme.dart';
import 'theme_data.dart';
......@@ -245,7 +246,7 @@ class _FilterChipDefaultsM3 extends ChipThemeData {
? isEnabled
? BorderSide(color: Theme.of(context).colorScheme.outline)
: BorderSide(color: Theme.of(context).colorScheme.onSurface.withOpacity(0.12))
: null;
: const BorderSide(color: Colors.transparent);
@override
IconThemeData? get iconTheme => IconThemeData(
......
......@@ -172,4 +172,43 @@ void main() {
await tester.pumpWidget(wrapForChip(child: FilterChip(label: label, onSelected: (bool b) { }, clipBehavior: Clip.antiAlias)));
checkChipMaterialClipBehavior(tester, Clip.antiAlias);
});
testWidgets('M3 width should not change with selection', (WidgetTester tester) async {
// Regression tests for: https://github.com/flutter/flutter/issues/110645
// For the text "FilterChip" the chip should default to 175 regardless of selection.
const int expectedWidth = 175;
// Unselected
await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: true),
home: Material(
child: Center(
child: FilterChip(
label: const Text('FilterChip'),
showCheckmark: false,
onSelected: (bool _) {},
)
),
),
));
expect(tester.getSize(find.byType(FilterChip)).width, expectedWidth);
// Selected
await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: true),
home: Material(
child: Center(
child: FilterChip(
label: const Text('FilterChip'),
showCheckmark: false,
selected: true,
onSelected: (bool _) {},
)
),
),
));
await tester.pumpAndSettle();
expect(tester.getSize(find.byType(FilterChip)).width, expectedWidth);
});
}
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