Fix InputDecorator.prefixIcon color when disabled (#149595)
## Description This PRs makes the `InputDecoration.prefixIcon` color compliant with the M3 spec. From M3 spec, the color should be `onSurface.withOpacity(0.38)`, see https://m3.material.io/components/text-fields/specs#e4964192-72ad-414f-85b4-4b4357abb83c  ## Related Issue Fixes https://github.com/flutter/flutter/issues/149411. ## Tests Updates 2 tests.
This commit is contained in:
@@ -4736,6 +4736,9 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
|
||||
|
||||
@override
|
||||
Color? get prefixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return _colors.onSurface.withOpacity(0.38);
|
||||
}
|
||||
return _colors.onSurfaceVariant;
|
||||
});
|
||||
|
||||
|
||||
@@ -5443,9 +5443,7 @@ void main() {
|
||||
);
|
||||
|
||||
final ThemeData theme = Theme.of(tester.element(findPrefixIcon()));
|
||||
// TODO(bleroux): based on M3 spec, it should be theme.colorScheme.onSurface.withOpacity(0.38).
|
||||
// See https://github.com/flutter/flutter/issues/149411.
|
||||
final Color expectedColor = theme.colorScheme.onSurfaceVariant;
|
||||
final Color expectedColor = theme.colorScheme.onSurface.withOpacity(0.38);
|
||||
expect(getPrefixIconStyle(tester).color, expectedColor);
|
||||
});
|
||||
|
||||
@@ -5921,9 +5919,7 @@ void main() {
|
||||
);
|
||||
|
||||
final ThemeData theme = Theme.of(tester.element(findPrefixIcon()));
|
||||
// TODO(bleroux): based on M3 spec, it should be theme.colorScheme.onSurface.withOpacity(0.38).
|
||||
// See https://github.com/flutter/flutter/issues/149411.
|
||||
final Color expectedColor = theme.colorScheme.onSurfaceVariant;
|
||||
final Color expectedColor = theme.colorScheme.onSurface.withOpacity(0.38);
|
||||
expect(getPrefixIconStyle(tester).color, expectedColor);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user