@@ -71,8 +71,10 @@ void main() {
7171 DateTime ? currentDate,
7272 ValueChanged <DateTime >? onChanged,
7373 TextDirection textDirection = TextDirection .ltr,
74+ ThemeData ? theme,
7475 }) {
7576 return MaterialApp (
77+ theme: theme,
7678 home: Material (
7779 child: Directionality (
7880 textDirection: textDirection,
@@ -2102,6 +2104,84 @@ void main() {
21022104 });
21032105 });
21042106
2107+ ShapeDecoration ? findYearDecoration (WidgetTester tester, String year) {
2108+ final Container container = tester.widget <Container >(
2109+ find.ancestor (of: find.text (year), matching: find.byType (Container )).first,
2110+ );
2111+
2112+ return container.decoration as ShapeDecoration ? ;
2113+ }
2114+
2115+ // Regression test for https://github.com/flutter/flutter/issues/189298
2116+ testWidgets ('Non-null todayBorder color should be respected over todayForegroundColor' , (
2117+ WidgetTester tester,
2118+ ) async {
2119+ const Color customBorderColor = Colors .red;
2120+ await tester.pumpWidget (
2121+ yearPicker (
2122+ theme: ThemeData (
2123+ datePickerTheme: DatePickerThemeData (
2124+ todayBorder: const BorderSide (color: customBorderColor),
2125+ todayForegroundColor: WidgetStateProperty .all (Colors .blue),
2126+ ),
2127+ ),
2128+ ),
2129+ );
2130+
2131+ // The current year should be painted with custom border color.
2132+ final ShapeDecoration ? decoration = findYearDecoration (tester, '2016' );
2133+ final shape = decoration! .shape as OutlinedBorder ;
2134+ expect (shape.side.color, customBorderColor);
2135+ });
2136+
2137+ // Regression test for https://github.com/flutter/flutter/issues/189298.
2138+ testWidgets ('Non-null todayBorder color is used even when disabled' , (WidgetTester tester) async {
2139+ const Color customBorderColor = Colors .red;
2140+ await tester.pumpWidget (
2141+ yearPicker (
2142+ firstDate: DateTime (2018 , DateTime .june, 9 ),
2143+ lastDate: DateTime (2030 , DateTime .december, 15 ),
2144+ selectedDate: DateTime (2020 ),
2145+ currentDate: DateTime (2016 ), // Not between first and last date.
2146+ theme: ThemeData (
2147+ datePickerTheme: DatePickerThemeData (
2148+ todayBorder: const BorderSide (color: customBorderColor),
2149+ todayForegroundColor: WidgetStateProperty .all (Colors .blue),
2150+ ),
2151+ ),
2152+ ),
2153+ );
2154+
2155+ // The current year should be painted with the custom border color,
2156+ // not with foreground color opacity applied, even if it's disabled.
2157+ final ShapeDecoration ? decoration = findYearDecoration (tester, '2016' );
2158+ final shape = decoration! .shape as OutlinedBorder ;
2159+ expect (shape.side.color, customBorderColor);
2160+ });
2161+
2162+ // Regression test for https://github.com/flutter/flutter/issues/189298.
2163+ testWidgets ('Transparent todayBorder should fall back to foreground color' , (
2164+ WidgetTester tester,
2165+ ) async {
2166+ const Color customForegroundColor = Colors .green;
2167+ await tester.pumpWidget (
2168+ yearPicker (
2169+ theme: ThemeData (
2170+ datePickerTheme: DatePickerThemeData (
2171+ todayBorder: const BorderSide (color: Color (0x00000000 )),
2172+ todayForegroundColor: WidgetStateProperty .all (customForegroundColor),
2173+ ),
2174+ ),
2175+ ),
2176+ );
2177+
2178+ // The current year should use the foreground color since
2179+ // todayBorder color is transparent.
2180+ final ShapeDecoration ? decoration = findYearDecoration (tester, '2016' );
2181+ final shape = decoration! .shape as OutlinedBorder ;
2182+ expect (shape.side.color, customForegroundColor);
2183+ });
2184+
21052185 group ('Calendar Delegate' , () {
21062186 testWidgets ('Defaults to Gregorian calendar system' , (WidgetTester tester) async {
21072187 await tester.pumpWidget (
0 commit comments