Skip to content

Commit b25ec17

Browse files
authored
Fix DateRangePickerDialog does not inherit local InputDecorationTheme (flutter#177086)
## Description This PR replaces global `ThemeData.inputDecorationTheme` usage in `DateRangePickerDialog` with `InputDecorationTheme.of ` which returns the ambient `InputDecorationTheme`. It is a follow up to flutter#168981 which introduces `InputDecorationTheme.of `. ## Related Issue Fixes [DateRangePickerDialog does not inherit local InputDecorationTheme](flutter#177083) ## Tests - Adds 1 test
1 parent 83382d1 commit b25ec17

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

packages/flutter/lib/src/material/date_picker.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3436,7 +3436,7 @@ class _InputDateRangePickerState extends State<_InputDateRangePicker> {
34363436
final ThemeData theme = Theme.of(context);
34373437
final bool useMaterial3 = theme.useMaterial3;
34383438
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
3439-
final InputDecorationThemeData inputTheme = theme.inputDecorationTheme;
3439+
final InputDecorationThemeData inputTheme = InputDecorationTheme.of(context);
34403440
final InputBorder inputBorder =
34413441
inputTheme.border ??
34423442
(useMaterial3 ? const OutlineInputBorder() : const UnderlineInputBorder());

packages/flutter/test/material/date_range_picker_test.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,6 +1980,31 @@ void main() {
19801980
);
19811981
expect(tester.getSize(find.byType(DateRangePickerDialog)), Size.zero);
19821982
});
1983+
1984+
// Regression test for https://github.com/flutter/flutter/issues/177083.
1985+
testWidgets('Local InputDecorationTheme is honored', (WidgetTester tester) async {
1986+
await tester.pumpWidget(
1987+
MaterialApp(
1988+
home: Center(
1989+
child: InputDecorationTheme(
1990+
data: const InputDecorationThemeData(filled: true),
1991+
child: DateRangePickerDialog(
1992+
firstDate: firstDate,
1993+
lastDate: lastDate,
1994+
currentDate: DateTime(2016, DateTime.january, 30),
1995+
initialEntryMode: DatePickerEntryMode.inputOnly,
1996+
),
1997+
),
1998+
),
1999+
),
2000+
);
2001+
2002+
final InputDecoration startDateDecoration = tester
2003+
.widget<TextField>(find.byType(TextField).first)
2004+
.decoration!;
2005+
2006+
expect(startDateDecoration.filled, isTrue);
2007+
});
19832008
}
19842009

19852010
class _RestorableDateRangePickerDialogTestWidget extends StatefulWidget {

0 commit comments

Comments
 (0)