@@ -31,29 +31,7 @@ void main() {
3131 );
3232
3333 final Material material = tester.widget <Material >(searchBarMaterial);
34- expect (material.animationDuration, const Duration (milliseconds: 200 ));
35- expect (material.borderOnForeground, true );
36- expect (material.borderRadius, null );
37- expect (material.clipBehavior, Clip .none);
38- expect (material.color, colorScheme.surface);
39- expect (material.elevation, 6.0 );
40- expect (material.shadowColor, colorScheme.shadow);
41- expect (material.surfaceTintColor, colorScheme.surfaceTint);
42- expect (material.shape, const StadiumBorder ());
43-
44- final Text helperText = tester.widget (find.text ('hint text' ));
45- expect (helperText.style? .color, colorScheme.onSurfaceVariant);
46- expect (helperText.style? .fontSize, 16.0 );
47- expect (helperText.style? .fontFamily, 'Roboto' );
48- expect (helperText.style? .fontWeight, FontWeight .w400);
49-
50- const String input = 'entered text' ;
51- await tester.enterText (find.byType (SearchBar ), input);
52- final EditableText inputText = tester.widget (find.text (input));
53- expect (inputText.style.color, colorScheme.onSurface);
54- expect (inputText.style.fontSize, 16.0 );
55- expect (helperText.style? .fontFamily, 'Roboto' );
56- expect (inputText.style.fontWeight, FontWeight .w400);
34+ checkSearchBarDefaults (tester, colorScheme, material);
5735 });
5836
5937 testWidgets ('SearchBar respects controller property' , (WidgetTester tester) async {
@@ -643,19 +621,21 @@ void main() {
643621 // On hovered.
644622 final TestGesture gesture = await _pointGestureToSearchBar (tester);
645623 await tester.pump ();
646- final Text helperText = tester.widget (find.text ('hint text' ));
624+ Text helperText = tester.widget (find.text ('hint text' ));
647625 expect (helperText.style? .color, hoveredColor);
648626
649627 // On pressed.
650628 await gesture.down (tester.getCenter (find.byType (SearchBar )));
651629 await tester.pump ();
630+ helperText = tester.widget (find.text ('hint text' ));
631+ expect (helperText.style? .color, pressedColor);
652632 await gesture.removePointer ();
653- expect (helperText.style? .color, hoveredColor);
654633
655634 // On focused.
656635 await tester.tap (find.byType (SearchBar ));
657636 await tester.pump ();
658- expect (helperText.style? .color, hoveredColor);
637+ helperText = tester.widget (find.text ('hint text' ));
638+ expect (helperText.style? .color, focusedColor);
659639 });
660640
661641 testWidgets ('SearchBar respects textStyle property' , (WidgetTester tester) async {
@@ -676,19 +656,21 @@ void main() {
676656 // On hovered.
677657 final TestGesture gesture = await _pointGestureToSearchBar (tester);
678658 await tester.pump ();
679- final EditableText inputText = tester.widget (find.text ('input text' ));
659+ EditableText inputText = tester.widget (find.text ('input text' ));
680660 expect (inputText.style.color, hoveredColor);
681661
682662 // On pressed.
683663 await gesture.down (tester.getCenter (find.byType (SearchBar )));
684664 await tester.pump ();
685665 await gesture.removePointer ();
686- expect (inputText.style.color, hoveredColor);
666+ inputText = tester.widget (find.text ('input text' ));
667+ expect (inputText.style.color, pressedColor);
687668
688669 // On focused.
689670 await tester.tap (find.byType (SearchBar ));
690671 await tester.pump ();
691- expect (inputText.style.color, hoveredColor);
672+ inputText = tester.widget (find.text ('input text' ));
673+ expect (inputText.style.color, focusedColor);
692674 });
693675
694676 testWidgets ('hintStyle can override textStyle for hintText' , (WidgetTester tester) async {
@@ -709,19 +691,21 @@ void main() {
709691 // On hovered.
710692 final TestGesture gesture = await _pointGestureToSearchBar (tester);
711693 await tester.pump ();
712- final Text helperText = tester.widget (find.text ('hint text' ));
694+ Text helperText = tester.widget (find.text ('hint text' ));
713695 expect (helperText.style? .color, hoveredColor);
714696
715697 // On pressed.
716698 await gesture.down (tester.getCenter (find.byType (SearchBar )));
717699 await tester.pump ();
718700 await gesture.removePointer ();
719- expect (helperText.style? .color, hoveredColor);
701+ helperText = tester.widget (find.text ('hint text' ));
702+ expect (helperText.style? .color, pressedColor);
720703
721704 // On focused.
722705 await tester.tap (find.byType (SearchBar ));
723706 await tester.pump ();
724- expect (helperText.style? .color, hoveredColor);
707+ helperText = tester.widget (find.text ('hint text' ));
708+ expect (helperText.style? .color, focusedColor);
725709 });
726710
727711 testWidgets ('The search view defaults' , (WidgetTester tester) async {
@@ -1761,6 +1745,161 @@ void main() {
17611745 final Rect searchViewRect = tester.getRect (find.descendant (of: findViewContent (), matching: find.byType (SizedBox )).first);
17621746 expect (searchViewRect.topLeft, equals (const Offset (rootSpacing, rootSpacing)));
17631747 });
1748+
1749+
1750+ // regression tests for https://github.com/flutter/flutter/issues/126623
1751+ group ('Overall InputDecorationTheme does not impact SearchBar and SearchView' , () {
1752+
1753+ const InputDecorationTheme inputDecorationTheme = InputDecorationTheme (
1754+ focusColor: Colors .green,
1755+ hoverColor: Colors .blue,
1756+ outlineBorder: BorderSide (color: Colors .pink, width: 10 ),
1757+ isDense: true ,
1758+ contentPadding: EdgeInsets .symmetric (horizontal: 20 ),
1759+ hintStyle: TextStyle (color: Colors .purpleAccent),
1760+ fillColor: Colors .tealAccent,
1761+ filled: true ,
1762+ isCollapsed: true ,
1763+ border: OutlineInputBorder (),
1764+ focusedBorder: UnderlineInputBorder (),
1765+ enabledBorder: UnderlineInputBorder (),
1766+ errorBorder: UnderlineInputBorder (),
1767+ focusedErrorBorder: UnderlineInputBorder (),
1768+ disabledBorder: UnderlineInputBorder (),
1769+ constraints: BoxConstraints (maxWidth: 300 ),
1770+ );
1771+ final ThemeData theme = ThemeData (
1772+ useMaterial3: true ,
1773+ inputDecorationTheme: inputDecorationTheme
1774+ );
1775+
1776+ void checkDecorationInSearchBar (WidgetTester tester) {
1777+ final Finder textField = findTextField ();
1778+ final InputDecoration ? decoration = tester.widget <TextField >(textField).decoration;
1779+
1780+ expect (decoration? .border, InputBorder .none);
1781+ expect (decoration? .focusedBorder, InputBorder .none);
1782+ expect (decoration? .enabledBorder, InputBorder .none);
1783+ expect (decoration? .errorBorder, null );
1784+ expect (decoration? .focusedErrorBorder, null );
1785+ expect (decoration? .disabledBorder, null );
1786+ expect (decoration? .constraints, null );
1787+ expect (decoration? .isCollapsed, false );
1788+ expect (decoration? .filled, false );
1789+ expect (decoration? .fillColor, null );
1790+ expect (decoration? .focusColor, null );
1791+ expect (decoration? .hoverColor, null );
1792+ expect (decoration? .contentPadding, const EdgeInsets .fromLTRB (0.0 , 12.0 , 0.0 , 12.0 ));
1793+ expect (decoration? .hintStyle? .color, theme.colorScheme.onSurfaceVariant);
1794+ }
1795+
1796+ testWidgets ('Overall InputDecorationTheme does not override text field style'
1797+ ' in SearchBar' , (WidgetTester tester) async {
1798+ await tester.pumpWidget (
1799+ MaterialApp (
1800+ theme: theme,
1801+ home: const Center (
1802+ child: Material (
1803+ child: SearchBar (hintText: 'hint text' ),
1804+ ),
1805+ ),
1806+ ),
1807+ );
1808+
1809+ // Check input decoration in `SearchBar`
1810+ checkDecorationInSearchBar (tester);
1811+
1812+ // Check search bar defaults.
1813+ final Finder searchBarMaterial = find.descendant (
1814+ of: find.byType (SearchBar ),
1815+ matching: find.byType (Material ),
1816+ );
1817+
1818+ final Material material = tester.widget <Material >(searchBarMaterial);
1819+ checkSearchBarDefaults (tester, theme.colorScheme, material);
1820+ });
1821+
1822+ testWidgets ('Overall InputDecorationTheme does not override text field style'
1823+ ' in the search view route' , (WidgetTester tester) async {
1824+ await tester.pumpWidget (
1825+ MaterialApp (
1826+ theme: theme,
1827+ home: Scaffold (
1828+ body: Material (
1829+ child: Align (
1830+ alignment: Alignment .topLeft,
1831+ child: SearchAnchor (
1832+ viewHintText: 'hint text' ,
1833+ builder: (BuildContext context, SearchController controller) {
1834+ return const Icon (Icons .search);
1835+ },
1836+ suggestionsBuilder: (BuildContext context, SearchController controller) {
1837+ return < Widget > [];
1838+ },
1839+ ),
1840+ ),
1841+ ),
1842+ ),
1843+ ),
1844+ );
1845+
1846+ await tester.tap (find.byIcon (Icons .search));
1847+ await tester.pumpAndSettle ();
1848+
1849+ // Check input decoration in `SearchBar`
1850+ checkDecorationInSearchBar (tester);
1851+
1852+ // Check search bar defaults in search view route.
1853+ final Finder searchBarMaterial = find.descendant (
1854+ of: find.descendant (of: findViewContent (), matching: find.byType (SearchBar )),
1855+ matching: find.byType (Material ),
1856+ ).first;
1857+
1858+ final Material material = tester.widget <Material >(searchBarMaterial);
1859+ expect (material.color, Colors .transparent);
1860+ expect (material.elevation, 0.0 );
1861+ final Text hintText = tester.widget (find.text ('hint text' ));
1862+ expect (hintText.style? .color, theme.colorScheme.onSurfaceVariant);
1863+
1864+ const String input = 'entered text' ;
1865+ await tester.enterText (find.byType (SearchBar ), input);
1866+ final EditableText inputText = tester.widget (find.text (input));
1867+ expect (inputText.style.color, theme.colorScheme.onSurface);
1868+ });
1869+ });
1870+ }
1871+
1872+ Future <void > checkSearchBarDefaults (WidgetTester tester, ColorScheme colorScheme, Material material) async {
1873+ expect (material.animationDuration, const Duration (milliseconds: 200 ));
1874+ expect (material.borderOnForeground, true );
1875+ expect (material.borderRadius, null );
1876+ expect (material.clipBehavior, Clip .none);
1877+ expect (material.color, colorScheme.surface);
1878+ expect (material.elevation, 6.0 );
1879+ expect (material.shadowColor, colorScheme.shadow);
1880+ expect (material.surfaceTintColor, colorScheme.surfaceTint);
1881+ expect (material.shape, const StadiumBorder ());
1882+
1883+ final Text helperText = tester.widget (find.text ('hint text' ));
1884+ expect (helperText.style? .color, colorScheme.onSurfaceVariant);
1885+ expect (helperText.style? .fontSize, 16.0 );
1886+ expect (helperText.style? .fontFamily, 'Roboto' );
1887+ expect (helperText.style? .fontWeight, FontWeight .w400);
1888+
1889+ const String input = 'entered text' ;
1890+ await tester.enterText (find.byType (SearchBar ), input);
1891+ final EditableText inputText = tester.widget (find.text (input));
1892+ expect (inputText.style.color, colorScheme.onSurface);
1893+ expect (inputText.style.fontSize, 16.0 );
1894+ expect (helperText.style? .fontFamily, 'Roboto' );
1895+ expect (inputText.style.fontWeight, FontWeight .w400);
1896+ }
1897+
1898+ Finder findTextField () {
1899+ return find.descendant (
1900+ of: find.byType (SearchBar ),
1901+ matching: find.byType (TextField )
1902+ );
17641903}
17651904
17661905TextStyle ? _iconStyle (WidgetTester tester, IconData icon) {
0 commit comments