Commit 1bc84024 authored by guoskyhero's avatar guoskyhero Committed by Justin McCandless

Add hintStyle in SearchDelegate (#30388)

SearchDelegate hintStyle parameter
parent 336e4c4c
......@@ -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;
}
}
}
\ No newline at end of file
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