Made insetPadding configurable for Date Picker Dialog (#155651)
This PR adds following properties to the **DatePickerDialog**: - `insetPadding`
This commit is contained in:
parent
5f65bd06c0
commit
19d8fbc6f4
@ -334,6 +334,7 @@ class DatePickerDialog extends StatefulWidget {
|
|||||||
this.onDatePickerModeChange,
|
this.onDatePickerModeChange,
|
||||||
this.switchToInputEntryModeIcon,
|
this.switchToInputEntryModeIcon,
|
||||||
this.switchToCalendarEntryModeIcon,
|
this.switchToCalendarEntryModeIcon,
|
||||||
|
this.insetPadding = const EdgeInsets.symmetric(horizontal: 16.0, vertical: 24.0),
|
||||||
}) : initialDate = initialDate == null ? null : DateUtils.dateOnly(initialDate),
|
}) : initialDate = initialDate == null ? null : DateUtils.dateOnly(initialDate),
|
||||||
firstDate = DateUtils.dateOnly(firstDate),
|
firstDate = DateUtils.dateOnly(firstDate),
|
||||||
lastDate = DateUtils.dateOnly(lastDate),
|
lastDate = DateUtils.dateOnly(lastDate),
|
||||||
@ -436,7 +437,6 @@ class DatePickerDialog extends StatefulWidget {
|
|||||||
/// Flutter.
|
/// Flutter.
|
||||||
final String? restorationId;
|
final String? restorationId;
|
||||||
|
|
||||||
|
|
||||||
/// Called when the [DatePickerDialog] is toggled between
|
/// Called when the [DatePickerDialog] is toggled between
|
||||||
/// [DatePickerEntryMode.calendar],[DatePickerEntryMode.input].
|
/// [DatePickerEntryMode.calendar],[DatePickerEntryMode.input].
|
||||||
///
|
///
|
||||||
@ -451,6 +451,13 @@ class DatePickerDialog extends StatefulWidget {
|
|||||||
/// {@macro flutter.material.date_picker.switchToCalendarEntryModeIcon}
|
/// {@macro flutter.material.date_picker.switchToCalendarEntryModeIcon}
|
||||||
final Icon? switchToCalendarEntryModeIcon;
|
final Icon? switchToCalendarEntryModeIcon;
|
||||||
|
|
||||||
|
/// The amount of padding added to [MediaQueryData.viewInsets] on the outside
|
||||||
|
/// of the dialog. This defines the minimum space between the screen's edges
|
||||||
|
/// and the dialog.
|
||||||
|
///
|
||||||
|
/// Defaults to `EdgeInsets.symmetric(horizontal: 16.0, vertical: 24.0)`.
|
||||||
|
final EdgeInsets insetPadding;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<DatePickerDialog> createState() => _DatePickerDialogState();
|
State<DatePickerDialog> createState() => _DatePickerDialogState();
|
||||||
}
|
}
|
||||||
@ -520,9 +527,7 @@ class _DatePickerDialogState extends State<DatePickerDialog> with RestorationMix
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handleDateChanged(DateTime date) {
|
void _handleDateChanged(DateTime date) {
|
||||||
setState(() {
|
setState(() => _selectedDate.value = date);
|
||||||
_selectedDate.value = date;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Size _dialogSize(BuildContext context) {
|
Size _dialogSize(BuildContext context) {
|
||||||
@ -725,7 +730,7 @@ class _DatePickerDialogState extends State<DatePickerDialog> with RestorationMix
|
|||||||
shape: useMaterial3
|
shape: useMaterial3
|
||||||
? datePickerTheme.shape ?? defaults.shape
|
? datePickerTheme.shape ?? defaults.shape
|
||||||
: datePickerTheme.shape ?? dialogTheme.shape ?? defaults.shape,
|
: datePickerTheme.shape ?? dialogTheme.shape ?? defaults.shape,
|
||||||
insetPadding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 24.0),
|
insetPadding: widget.insetPadding,
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: AnimatedContainer(
|
child: AnimatedContainer(
|
||||||
width: dialogSize.width,
|
width: dialogSize.width,
|
||||||
|
@ -2181,6 +2181,22 @@ void main() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('DatePickerDialog with updated insetPadding', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(MaterialApp(
|
||||||
|
home: Material(
|
||||||
|
child: DatePickerDialog(
|
||||||
|
initialDate: initialDate,
|
||||||
|
firstDate: firstDate,
|
||||||
|
lastDate: lastDate,
|
||||||
|
insetPadding: const EdgeInsets.fromLTRB(10.0, 20.0, 30.0, 40.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
final Dialog dialog = tester.widget<Dialog>(find.byType(Dialog));
|
||||||
|
expect(dialog.insetPadding, const EdgeInsets.fromLTRB(10.0, 20.0, 30.0, 40.0));
|
||||||
|
});
|
||||||
|
|
||||||
group('Landscape input-only date picker headers use headlineSmall', () {
|
group('Landscape input-only date picker headers use headlineSmall', () {
|
||||||
// Regression test for https://github.com/flutter/flutter/issues/122056
|
// Regression test for https://github.com/flutter/flutter/issues/122056
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user