mirror of
https://github.com/flutter/flutter
synced 2024-07-05 01:48:58 +00:00
fix M2 InputDecorator suffix icon doesn't turn red on error (#149161)
The suffixIcon of a TextField with an error now turns red like it should (on Material 2).
This commit is contained in:
parent
e2e68c047c
commit
fdca33c5b1
|
@ -4570,7 +4570,7 @@ class _InputDecoratorDefaultsM2 extends InputDecorationTheme {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TextStyle? get helperStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
|
TextStyle? get helperStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
|
||||||
final ThemeData themeData= Theme.of(context);
|
final ThemeData themeData = Theme.of(context);
|
||||||
if (states.contains(MaterialState.disabled)) {
|
if (states.contains(MaterialState.disabled)) {
|
||||||
return themeData.textTheme.bodySmall!.copyWith(color: Colors.transparent);
|
return themeData.textTheme.bodySmall!.copyWith(color: Colors.transparent);
|
||||||
}
|
}
|
||||||
|
@ -4580,7 +4580,7 @@ class _InputDecoratorDefaultsM2 extends InputDecorationTheme {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TextStyle? get errorStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
|
TextStyle? get errorStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
|
||||||
final ThemeData themeData= Theme.of(context);
|
final ThemeData themeData = Theme.of(context);
|
||||||
if (states.contains(MaterialState.disabled)) {
|
if (states.contains(MaterialState.disabled)) {
|
||||||
return themeData.textTheme.bodySmall!.copyWith(color: Colors.transparent);
|
return themeData.textTheme.bodySmall!.copyWith(color: Colors.transparent);
|
||||||
}
|
}
|
||||||
|
@ -4630,6 +4630,9 @@ class _InputDecoratorDefaultsM2 extends InputDecorationTheme {
|
||||||
if (states.contains(MaterialState.disabled) && !states.contains(MaterialState.focused)) {
|
if (states.contains(MaterialState.disabled) && !states.contains(MaterialState.focused)) {
|
||||||
return Theme.of(context).disabledColor;
|
return Theme.of(context).disabledColor;
|
||||||
}
|
}
|
||||||
|
if (states.contains(MaterialState.error)) {
|
||||||
|
return Theme.of(context).colorScheme.error;
|
||||||
|
}
|
||||||
if (states.contains(MaterialState.focused)) {
|
if (states.contains(MaterialState.focused)) {
|
||||||
return Theme.of(context).colorScheme.primary;
|
return Theme.of(context).colorScheme.primary;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8885,6 +8885,29 @@ void main() {
|
||||||
expect(tester.getTopRight(find.text('text')).dx, lessThanOrEqualTo(tester.getTopLeft(find.byIcon(Icons.satellite)).dx));
|
expect(tester.getTopRight(find.text('text')).dx, lessThanOrEqualTo(tester.getTopLeft(find.byIcon(Icons.satellite)).dx));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('Material2 - InputDecorator suffixIcon color in error state', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
theme: ThemeData(useMaterial3: false),
|
||||||
|
home: Material(
|
||||||
|
child: TextField(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
icon: const Icon(Icons.close),
|
||||||
|
onPressed: () {},
|
||||||
|
),
|
||||||
|
errorText: 'Error state',
|
||||||
|
filled: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final ThemeData theme = Theme.of(tester.element(find.byType(TextField)));
|
||||||
|
expect(getIconStyle(tester, Icons.close)?.color, theme.colorScheme.error);
|
||||||
|
});
|
||||||
|
|
||||||
testWidgets('InputDecorator prefixIconConstraints/suffixIconConstraints', (WidgetTester tester) async {
|
testWidgets('InputDecorator prefixIconConstraints/suffixIconConstraints', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
buildInputDecoratorM2(
|
buildInputDecoratorM2(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user