diff --git a/packages/flutter/lib/src/material/search.dart b/packages/flutter/lib/src/material/search.dart index 75740f32b4..356854a2be 100644 --- a/packages/flutter/lib/src/material/search.dart +++ b/packages/flutter/lib/src/material/search.dart @@ -466,6 +466,7 @@ class _SearchPageState extends State<_SearchPage> { decoration: InputDecoration( border: InputBorder.none, hintText: searchFieldLabel, + hintStyle: theme.inputDecorationTheme.hintStyle, ), ), actions: widget.delegate.buildActions(context), diff --git a/packages/flutter/test/material/search_test.dart b/packages/flutter/test/material/search_test.dart index caec4278e6..6d93b34c0f 100644 --- a/packages/flutter/test/material/search_test.dart +++ b/packages/flutter/test/material/search_test.dart @@ -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(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 { final String suggestions; final String result; final List 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 { List buildActions(BuildContext context) { return actions; } -} +} \ No newline at end of file