Test InputDecoration API examples (#148560)
Add tests for `InputDecoration` API example as part of #130459. Updates examples that use the deprecated MaterialState to use WidgetState. Tests files: `input_decoration.0.dart`, `input_decoration.1.dart`, `input_decoration.2.dart`, `input_decoration.3.dart`, `input_decoration.widget_state.0.dart`, `input_decoration.widget_state.1.dart`, `input_decoration.prefix_icon_constraints.0.dart`, `input_decoration.suffix_icon_constraints.0.dart`, and `input_decoration.label.0.dart`
This commit is contained in:
@@ -32,13 +32,10 @@ class MaterialStateExample extends StatelessWidget {
|
||||
initialValue: 'abc',
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: const Icon(Icons.person),
|
||||
prefixIconColor: MaterialStateColor.resolveWith((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
prefixIconColor: WidgetStateColor.resolveWith((Set<WidgetState> states) {
|
||||
if (states.contains(WidgetState.focused)) {
|
||||
return Colors.green;
|
||||
}
|
||||
if (states.contains(MaterialState.error)) {
|
||||
return Colors.red;
|
||||
}
|
||||
return Colors.grey;
|
||||
}),
|
||||
),
|
||||
@@ -32,24 +32,31 @@ class MaterialStateExample extends StatelessWidget {
|
||||
return Theme(
|
||||
data: themeData.copyWith(
|
||||
inputDecorationTheme: themeData.inputDecorationTheme.copyWith(
|
||||
prefixIconColor: MaterialStateColor.resolveWith(
|
||||
(Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return Colors.green;
|
||||
}
|
||||
if (states.contains(MaterialState.error)) {
|
||||
prefixIconColor: WidgetStateColor.resolveWith(
|
||||
(Set<WidgetState> states) {
|
||||
if (states.contains(WidgetState.error)) {
|
||||
return Colors.red;
|
||||
}
|
||||
if (states.contains(WidgetState.focused)) {
|
||||
return Colors.blue;
|
||||
}
|
||||
return Colors.grey;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
child: TextFormField(
|
||||
initialValue: 'abc',
|
||||
initialValue: 'example.com',
|
||||
decoration: const InputDecoration(
|
||||
prefixIcon: Icon(Icons.person),
|
||||
prefixIcon: Icon(Icons.web),
|
||||
),
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
validator: (String? text) {
|
||||
if (text?.endsWith('.com') ?? false) {
|
||||
return null;
|
||||
}
|
||||
return 'No .com tld';
|
||||
}
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user