• 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
.github Loading commit data...
.vscode Loading commit data...
bin Loading commit data...
dev Loading commit data...
examples Loading commit data...
packages Loading commit data...
.ci.yaml Loading commit data...
.cirrus.yml Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CODEOWNERS Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
CONTRIBUTING.md Loading commit data...
LICENSE Loading commit data...
PATENT_GRANT Loading commit data...
README.md Loading commit data...
TESTOWNERS Loading commit data...
analysis_options.yaml Loading commit data...
dartdoc_options.yaml Loading commit data...
flutter_console.bat Loading commit data...