• Taha Tesser's avatar
    Fix `DatePickerDialog` & `DateRangePickerDialog` overflow when resized from... · a0943e65
    Taha Tesser authored
    Fix  `DatePickerDialog` & `DateRangePickerDialog` overflow when resized from landscape to portrait (#133327)
    
    fixes [resize window with a `showDateRangePicker` will make RenderFlex overflowed error](https://github.com/flutter/flutter/issues/131989)
    
    ### Description
    - This fixes  `DatePickerDialog` & `DateRangePickerDialog` overflow error when resized from landscape to portrait.
    - Added tests that check these two widgets from landscape to portrait for no overflow errors.
    
    <details
    <summary>expand to view the code sample</summary> 
    
    ```dart
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return const MaterialApp(
          debugShowCheckedModeBanner: false,
          home: Example(),
        );
      }
    }
    
    class Example extends StatefulWidget {
      const Example({super.key});
    
      @override
      State<Example> createState() => _ExampleState();
    }
    
    class _ExampleState extends State<Example> {
      bool _portait = false;
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: const Text('DatePicker & DateRangePicker'),
          ),
          body: MediaQuery(
            data: MediaQuery.of(context).copyWith(
              size: _portait ? const Size(400, 800) : const Size(800, 400),
            ),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: [
                DatePickerDialog(
                  initialDate: DateTime.now(),
                  firstDate: DateTime(2020),
                  lastDate: DateTime(2030),
                  initialEntryMode: DatePickerEntryMode.inputOnly,
                ),
                DateRangePickerDialog(
                  currentDate: DateTime.now(),
                  firstDate: DateTime(2020),
                  lastDate: DateTime(2030),
                  initialEntryMode: DatePickerEntryMode.inputOnly,
                ),
              ],
            ),
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: () {
              setState(() {
                _portait = !_portait;
              });
            },
            child: const Icon(Icons.refresh),
          ),
        );
      }
    }
    
    ```
    
    </details>
    
    ### Before
    
    https://github.com/flutter/flutter/assets/48603081/81387cbb-cdcf-42bd-b4f8-b7a08317c955
    
    ### After
    
    https://github.com/flutter/flutter/assets/48603081/36d28ea9-cfed-48ad-90f5-0459755e08c0
    a0943e65
Name
Last commit
Last update
..
lib Loading commit data...
test Loading commit data...
test_fixes Loading commit data...
test_private Loading commit data...
test_profile Loading commit data...
test_release Loading commit data...
LICENSE Loading commit data...
README.md Loading commit data...
analysis_options.yaml Loading commit data...
build.yaml Loading commit data...
dart_test.yaml Loading commit data...
pubspec.yaml Loading commit data...