Fixed an issue with FilterChip's changing size when selected due to border size. (#111916)
This commit is contained in:
parent
7f6c111c58
commit
ba489607a1
@ -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);
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user