Unverified Commit 6a1fc9ea authored by hangyu's avatar hangyu Committed by GitHub

InputDecorator iconColor/prefixIconColor/suffixIconColor (#109988)

parent c43e44b4
...@@ -1991,17 +1991,20 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat ...@@ -1991,17 +1991,20 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
} }
Color _getIconColor(ThemeData themeData, InputDecorationTheme defaults) { Color _getIconColor(ThemeData themeData, InputDecorationTheme defaults) {
return MaterialStateProperty.resolveAs(themeData.inputDecorationTheme.iconColor, materialState) return MaterialStateProperty.resolveAs(decoration.iconColor, materialState)
?? MaterialStateProperty.resolveAs(themeData.inputDecorationTheme.iconColor, materialState)
?? MaterialStateProperty.resolveAs(defaults.iconColor!, materialState); ?? MaterialStateProperty.resolveAs(defaults.iconColor!, materialState);
} }
Color _getPrefixIconColor(ThemeData themeData, InputDecorationTheme defaults) { Color _getPrefixIconColor(ThemeData themeData, InputDecorationTheme defaults) {
return MaterialStateProperty.resolveAs(themeData.inputDecorationTheme.prefixIconColor, materialState) return MaterialStateProperty.resolveAs(decoration.prefixIconColor, materialState)
?? MaterialStateProperty.resolveAs(themeData.inputDecorationTheme.prefixIconColor, materialState)
?? MaterialStateProperty.resolveAs(defaults.prefixIconColor!, materialState); ?? MaterialStateProperty.resolveAs(defaults.prefixIconColor!, materialState);
} }
Color _getSuffixIconColor(ThemeData themeData, InputDecorationTheme defaults) { Color _getSuffixIconColor(ThemeData themeData, InputDecorationTheme defaults) {
return MaterialStateProperty.resolveAs(themeData.inputDecorationTheme.suffixIconColor, materialState) return MaterialStateProperty.resolveAs(decoration.suffixIconColor, materialState)
?? MaterialStateProperty.resolveAs(themeData.inputDecorationTheme.suffixIconColor, materialState)
?? MaterialStateProperty.resolveAs(defaults.suffixIconColor!, materialState); ?? MaterialStateProperty.resolveAs(defaults.suffixIconColor!, materialState);
} }
......
...@@ -1657,6 +1657,30 @@ void main() { ...@@ -1657,6 +1657,30 @@ void main() {
expect(tester.getTopRight(find.text('text')).dx, lessThanOrEqualTo(tester.getTopLeft(find.text('s')).dx)); expect(tester.getTopRight(find.text('text')).dx, lessThanOrEqualTo(tester.getTopLeft(find.text('s')).dx));
}); });
testWidgets('InputDecorator iconColor/prefixIconColor/suffixIconColor', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Material(
child: TextField(
decoration: InputDecoration(
icon: Icon(Icons.cabin),
prefixIcon: Icon(Icons.sailing),
suffixIcon: Icon(Icons.close),
iconColor: Colors.amber,
prefixIconColor: Colors.green,
suffixIconColor: Colors.red,
filled: true,
),
),
),
),
);
expect(tester.widget<IconTheme>(find.widgetWithIcon(IconTheme,Icons.cabin).first).data.color, Colors.amber);
expect(tester.widget<IconTheme>(find.widgetWithIcon(IconTheme,Icons.sailing).first).data.color, Colors.green);
expect(tester.widget<IconTheme>(find.widgetWithIcon(IconTheme,Icons.close).first).data.color, Colors.red);
});
testWidgets('InputDecorator prefix/suffix widgets', (WidgetTester tester) async { testWidgets('InputDecorator prefix/suffix widgets', (WidgetTester tester) async {
const Key pKey = Key('p'); const Key pKey = Key('p');
const Key sKey = Key('s'); const Key sKey = Key('s');
......
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