Add hintStyle in SearchDelegate (#30388)
SearchDelegate hintStyle parameter
This commit is contained in:
committed by
Justin McCandless
parent
336e4c4c9f
commit
1bc8402478
@@ -466,6 +466,7 @@ class _SearchPageState<T> extends State<_SearchPage<T>> {
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
hintText: searchFieldLabel,
|
||||
hintStyle: theme.inputDecorationTheme.hintStyle,
|
||||
),
|
||||
),
|
||||
actions: widget.delegate.buildActions(context),
|
||||
|
||||
@@ -91,6 +91,20 @@ void main() {
|
||||
expect(find.text('Suggestions'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Hint text color overridden', (WidgetTester tester) async {
|
||||
final _TestSearchDelegate delegate = _TestSearchDelegate();
|
||||
|
||||
await tester.pumpWidget(TestHomePage(
|
||||
delegate: delegate,
|
||||
));
|
||||
await tester.tap(find.byTooltip('Search'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final TextField textField = tester.widget<TextField>(find.byType(TextField));
|
||||
final Color hintColor = textField.decoration.hintStyle.color;
|
||||
expect(hintColor, delegate.hintTextColor);
|
||||
});
|
||||
|
||||
testWidgets('Requests suggestions', (WidgetTester tester) async {
|
||||
final _TestSearchDelegate delegate = _TestSearchDelegate();
|
||||
|
||||
@@ -644,6 +658,15 @@ class _TestSearchDelegate extends SearchDelegate<String> {
|
||||
final String suggestions;
|
||||
final String result;
|
||||
final List<Widget> actions;
|
||||
final Color hintTextColor = Colors.green;
|
||||
|
||||
@override
|
||||
ThemeData appBarTheme(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
return theme.copyWith(
|
||||
inputDecorationTheme: InputDecorationTheme(hintStyle: TextStyle(color: hintTextColor)),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildLeading(BuildContext context) {
|
||||
@@ -680,4 +703,4 @@ class _TestSearchDelegate extends SearchDelegate<String> {
|
||||
List<Widget> buildActions(BuildContext context) {
|
||||
return actions;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user