Skip to content

Commit 9cf179b

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

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,10 @@ class _InputDatePickerFormFieldState extends State<InputDatePickerFormField> {
259259
final bool useMaterial3 = theme.useMaterial3;
260260
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
261261
final DatePickerThemeData datePickerTheme = theme.datePickerTheme;
262-
final InputDecorationThemeData inputTheme = theme.inputDecorationTheme;
262+
final InputDecorationThemeData inputTheme = InputDecorationTheme.of(context);
263263
final InputBorder effectiveInputBorder =
264264
datePickerTheme.inputDecorationTheme?.border ??
265-
theme.inputDecorationTheme.border ??
265+
inputTheme.border ??
266266
(useMaterial3 ? const OutlineInputBorder() : const UnderlineInputBorder());
267267

268268
return Semantics(

packages/flutter/test/material/input_date_picker_form_field_test.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,28 @@ void main() {
522522
);
523523
expect(tester.getSize(find.byType(InputDatePickerFormField)), Size.zero);
524524
});
525+
526+
// Regression test for https://github.com/flutter/flutter/issues/177088.
527+
testWidgets('Local InputDecorationTheme is honored', (WidgetTester tester) async {
528+
await tester.pumpWidget(
529+
MaterialApp(
530+
home: Material(
531+
child: Center(
532+
child: InputDecorationTheme(
533+
data: const InputDecorationThemeData(filled: true),
534+
child: InputDatePickerFormField(
535+
firstDate: DateTime(2025, DateTime.february),
536+
lastDate: DateTime(2026, DateTime.may),
537+
),
538+
),
539+
),
540+
),
541+
),
542+
);
543+
544+
final InputDecoration decoration = tester.widget<TextField>(find.byType(TextField)).decoration!;
545+
expect(decoration.filled, isTrue);
546+
});
525547
}
526548

527549
class TestCalendarDelegate extends GregorianCalendarDelegate {

0 commit comments

Comments
 (0)