• Taha Tesser's avatar
    Introduce `avatarBoxConstraints` & `deleteIconBoxConstraints` for the chips (#143302) · ccf42dde
    Taha Tesser authored
    fixes [Chip widget's avatar padding changing if label text is more than 1 line](https://github.com/flutter/flutter/issues/136892)
    
    ### Code sample
    
    <details>
    <summary>expand to view the code sample</summary> 
    
    ```dart
    import 'package:flutter/material.dart';
    
    List<String> strings = [
      'hello good morning',
      'hello good morning hello good morning',
      'hello good morning hello good morning hello good morning'
    ];
    
    void main() => runApp(const MyApp());
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          debugShowCheckedModeBanner: false,
          home: Scaffold(
            body: Center(
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  Column(
                    mainAxisSize: MainAxisSize.min,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      const Text(
                          'avatarBoxConstraints: null \ndeleteIconBoxConstraints: null',
                          textAlign: TextAlign.center),
                      for (String string in strings)
                        Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: RawChip(
                            label: Container(
                              width: 150,
                              color: Colors.amber,
                              child: Text(
                                string,
                                maxLines: 3,
                                overflow: TextOverflow.ellipsis,
                              ),
                            ),
                            avatar: const Icon(Icons.settings),
                            onDeleted: () {},
                          ),
                        ),
                    ],
                  ),
                  Column(
                    mainAxisSize: MainAxisSize.min,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      const Text(
                          'avatarBoxConstraints: BoxConstraints.tightForFinite() \ndeleteIconBoxConstraints: BoxConstraints.tightForFinite()',
                          textAlign: TextAlign.center),
                      for (String string in strings)
                        Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: RawChip(
                            avatarBoxConstraints:
                                const BoxConstraints.tightForFinite(),
                            deleteIconBoxConstraints:
                                const BoxConstraints.tightForFinite(),
                            label: Container(
                              width: 150,
                              color: Colors.amber,
                              child: Text(
                                string,
                                maxLines: 3,
                                overflow: TextOverflow.ellipsis,
                              ),
                            ),
                            avatar: const Icon(Icons.settings),
                            onDeleted: () {},
                          ),
                        ),
                    ],
                  ),
                ],
              ),
            ),
          ),
        );
      }
    }
    
    ```
    
    </details>
    
    ### Preview
    ![Screenshot 2024-02-12 at 14 58 35](https://github.com/flutter/flutter/assets/48603081/5724bd07-7ac7-4987-b992-fa3ab8488273)
    
    # Example previews
    ![Screenshot 2024-02-12 at 22 15 14](https://github.com/flutter/flutter/assets/48603081/33af472d-3561-47d4-8d0d-e1628de1e0aa)
    ![Screenshot 2024-02-12 at 22 15 46](https://github.com/flutter/flutter/assets/48603081/3de78b59-5cb6-4fd8-879b-8e204aacb069)
    ccf42dde
Name
Last commit
Last update
..
about Loading commit data...
action_buttons Loading commit data...
action_chip Loading commit data...
animated_icon Loading commit data...
app Loading commit data...
app_bar Loading commit data...
autocomplete Loading commit data...
banner Loading commit data...
bottom_app_bar Loading commit data...
bottom_navigation_bar Loading commit data...
bottom_sheet Loading commit data...
button_style Loading commit data...
button_style_button Loading commit data...
card Loading commit data...
checkbox Loading commit data...
checkbox_list_tile Loading commit data...
chip Loading commit data...
choice_chip Loading commit data...
color_scheme Loading commit data...
context_menu Loading commit data...
data_table Loading commit data...
date_picker Loading commit data...
dialog Loading commit data...
divider Loading commit data...
drawer Loading commit data...
dropdown Loading commit data...
dropdown_menu Loading commit data...
elevated_button Loading commit data...
expansion_panel Loading commit data...
expansion_tile Loading commit data...
filled_button Loading commit data...
filter_chip Loading commit data...
flexible_space_bar Loading commit data...
floating_action_button Loading commit data...
floating_action_button_location Loading commit data...
icon_button Loading commit data...
ink Loading commit data...
ink_well Loading commit data...
input_chip Loading commit data...
input_decorator Loading commit data...
list_tile Loading commit data...
material_state Loading commit data...
menu_anchor Loading commit data...
navigation_bar Loading commit data...
navigation_drawer Loading commit data...
navigation_rail Loading commit data...
outlined_button Loading commit data...
page_transitions_theme Loading commit data...
paginated_data_table Loading commit data...
platform_menu_bar Loading commit data...
popup_menu Loading commit data...
progress_indicator Loading commit data...
radio Loading commit data...
radio_list_tile Loading commit data...
range_slider Loading commit data...
refresh_indicator Loading commit data...
reorderable_list Loading commit data...
scaffold Loading commit data...
scrollbar Loading commit data...
search_anchor Loading commit data...
segmented_button Loading commit data...
selectable_region Loading commit data...
selection_area Loading commit data...
selection_container Loading commit data...
slider Loading commit data...
snack_bar Loading commit data...
stepper Loading commit data...
switch Loading commit data...
switch_list_tile Loading commit data...
tab_controller Loading commit data...
tabs Loading commit data...
text_button Loading commit data...
text_field Loading commit data...
text_form_field Loading commit data...
theme Loading commit data...
theme_data Loading commit data...
time_picker Loading commit data...
toggle_buttons Loading commit data...
tooltip Loading commit data...