mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Make sure that a DateRangePickerDialog doesn't crash in 0x0 environments (#173754)
This is my attempt to handle https://github.com/flutter/flutter/issues/6537 for the DateRangePickerDialog UI control.
This commit is contained in:
parent
4f49888a06
commit
7ceee3b074
@ -2395,8 +2395,10 @@ class _MonthItemGridDelegate extends SliverGridDelegate {
|
||||
|
||||
@override
|
||||
SliverGridLayout getLayout(SliverConstraints constraints) {
|
||||
final double tileWidth =
|
||||
(constraints.crossAxisExtent - 2 * _horizontalPadding) / DateTime.daysPerWeek;
|
||||
final double tileWidth = math.max(
|
||||
(constraints.crossAxisExtent - 2 * _horizontalPadding) / DateTime.daysPerWeek,
|
||||
0.0,
|
||||
);
|
||||
return _MonthSliverGridLayout(
|
||||
crossAxisCount: DateTime.daysPerWeek + 2,
|
||||
dayChildWidth: tileWidth,
|
||||
|
||||
@ -1967,6 +1967,19 @@ void main() {
|
||||
expect(getDayCount(secondMonthItem), 21);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('DateRangePickerDialog does not crash at zero area', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Center(
|
||||
child: SizedBox.shrink(
|
||||
child: DateRangePickerDialog(firstDate: firstDate, lastDate: lastDate),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(tester.getSize(find.byType(DateRangePickerDialog)), Size.zero);
|
||||
});
|
||||
}
|
||||
|
||||
class _RestorableDateRangePickerDialogTestWidget extends StatefulWidget {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user