deleteIconBoxConstraints property

BoxConstraints? get deleteIconBoxConstraints

Optional size constraints for the delete icon.

When unspecified, defaults to a minimum size of chip height or label height (whichever is greater) and a padding of 8.0 pixels on all sides.

The default constraints ensure that the delete icon is accessible. Specifying this parameter enables creation of delete icon smaller than the minimum size, but it is not recommended.

This sample shows how to use deleteIconBoxConstraints to adjust delete icon size constraints.

To see it in action, copy and run this code snippet on DartPad.

import 'package:material_ui/material_ui.dart';

/// Flutter code sample for [DeletableChipAttributes.deleteIconBoxConstraints].

void main() => runApp(const DeleteIconBoxConstraintsApp());

class DeleteIconBoxConstraintsApp extends StatelessWidget {
  const DeleteIconBoxConstraintsApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(body: Center(child: DeleteIconBoxConstraintsExample())),
    );
  }
}

class DeleteIconBoxConstraintsExample extends StatelessWidget {
  const DeleteIconBoxConstraintsExample({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: .center,
      children: <Widget>[
        RawChip(
          deleteIconBoxConstraints: const BoxConstraints.tightForFinite(),
          onDeleted: () {},
          label: const SizedBox(
            width: 150,
            child: Text('One line text.', maxLines: 3, overflow: .ellipsis),
          ),
        ),
        const SizedBox(height: 10),
        RawChip(
          deleteIconBoxConstraints: const BoxConstraints.tightForFinite(),
          onDeleted: () {},
          label: const SizedBox(
            width: 150,
            child: Text(
              'This text will wrap into two lines.',
              maxLines: 3,
              overflow: .ellipsis,
            ),
          ),
        ),
        const SizedBox(height: 10),
        RawChip(
          deleteIconBoxConstraints: const BoxConstraints.tightForFinite(),
          onDeleted: () {},
          label: const SizedBox(
            width: 150,
            child: Text(
              'This is a very long text that will wrap into three lines.',
              maxLines: 3,
              overflow: .ellipsis,
            ),
          ),
        ),
      ],
    );
  }
}

Implementation

// TODO(framework): Replace the following block with a @dartpad directive
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4123
/// {@macro material_ui.dartpad_guide}
///
/// {@example /example/lib/chip/deletable_chip_attributes.delete_icon_box_constraints.0.dart#body}
///
/// </callout-box>
BoxConstraints? get deleteIconBoxConstraints;