• Taha Tesser's avatar
    Add `cancelButtonStyle` & `confirmButtonStyle` to the `DatePickerThemeData` (#132847) · 1e770c38
    Taha Tesser authored
    fixes [Unable to adjust the color for "Cancel" and "Ok" button in datePicker dialog](https://github.com/flutter/flutter/issues/127739)
    
    ### Code sample
    
    <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 MaterialApp(
          debugShowCheckedModeBanner: false,
          theme: ThemeData(
            useMaterial3: true,
            datePickerTheme: DatePickerThemeData(
              cancelButtonStyle: TextButton.styleFrom(
                shape: const RoundedRectangleBorder(
                  borderRadius: BorderRadius.all(Radius.circular(16)),
                  side: BorderSide(color: Colors.red),
                ),
                backgroundColor: Colors.white,
                foregroundColor: Colors.red,
                elevation: 3,
                shadowColor: Colors.red,
              ),
              confirmButtonStyle: TextButton.styleFrom(
                shape: const RoundedRectangleBorder(
                  borderRadius: BorderRadius.all(Radius.circular(16)),
                ),
                backgroundColor: Colors.green[700],
                foregroundColor: Colors.white,
                elevation: 3,
                shadowColor: Colors.green[700],
              ),
            ),
          ),
          home: const Example(),
        );
      }
    }
    
    class Example extends StatelessWidget {
      const Example({super.key});
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Center(
            child: DatePickerDialog(
              initialDate: DateTime.now(),
              firstDate: DateTime(2020),
              lastDate: DateTime(2030),
            ),
          ),
        );
      }
    }
    ``` 
    
    </details>
    
    ### Before 
    
    Not possible to customize action buttons from the `DatePickerThemeData`.
    
    ### After 
    
    ![Screenshot 2023-08-18 at 16 42 00](https://github.com/flutter/flutter/assets/48603081/4ec01e93-c661-491d-9253-d687da8b76f3)
    1e770c38
Name
Last commit
Last update
..
action_chip_template.dart Loading commit data...
app_bar_template.dart Loading commit data...
badge_template.dart Loading commit data...
banner_template.dart Loading commit data...
bottom_app_bar_template.dart Loading commit data...
bottom_sheet_template.dart Loading commit data...
button_template.dart Loading commit data...
card_template.dart Loading commit data...
checkbox_template.dart Loading commit data...
chip_template.dart Loading commit data...
color_scheme_template.dart Loading commit data...
date_picker_template.dart Loading commit data...
dialog_template.dart Loading commit data...
divider_template.dart Loading commit data...
drawer_template.dart Loading commit data...
expansion_tile_template.dart Loading commit data...
fab_template.dart Loading commit data...
filter_chip_template.dart Loading commit data...
icon_button_template.dart Loading commit data...
input_chip_template.dart Loading commit data...
input_decorator_template.dart Loading commit data...
list_tile_template.dart Loading commit data...
menu_template.dart Loading commit data...
motion_template.dart Loading commit data...
navigation_bar_template.dart Loading commit data...
navigation_drawer_template.dart Loading commit data...
navigation_rail_template.dart Loading commit data...
popup_menu_template.dart Loading commit data...
progress_indicator_template.dart Loading commit data...
radio_template.dart Loading commit data...
search_bar_template.dart Loading commit data...
search_view_template.dart Loading commit data...
segmented_button_template.dart Loading commit data...
slider_template.dart Loading commit data...
snackbar_template.dart Loading commit data...
surface_tint.dart Loading commit data...
switch_template.dart Loading commit data...
tabs_template.dart Loading commit data...
template.dart Loading commit data...
text_field_template.dart Loading commit data...
time_picker_template.dart Loading commit data...
token_logger.dart Loading commit data...
typography_template.dart Loading commit data...