Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delete button support to FilterChip #136645

Merged
merged 1 commit into from Oct 23, 2023

Conversation

TahaTesser
Copy link
Member

fixes FilterChip should have DeletableChipAttributes/trailing to match Material 3 spec.

Code sample

expand to view the code sample
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),
      home: const Example(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text('FilterChip'),
            const SizedBox(height: 8),
            FilterChip(
              avatar: const Icon(Icons.favorite_rounded),
              label: const Text('FilterChip'),
              selected: true,
              showCheckmark: false,
              onSelected: (bool value) {},
              onDeleted: () {},
              deleteButtonTooltipMessage: 'Delete Me!',
            ),
            const SizedBox(height: 16),
            FilterChip(
              avatar: const Icon(Icons.favorite_rounded),
              label: const Text('FilterChip'),
              onSelected: (bool value) {},
              onDeleted: () {},
            ),
            const SizedBox(height: 48),
            const Text('FilterChip.elevated'),
            const SizedBox(height: 8),
            FilterChip.elevated(
              avatar: const Icon(Icons.favorite_rounded),
              label: const Text('FilterChip'),
              selected: true,
              showCheckmark: false,
              onSelected: (bool value) {},
              onDeleted: () {},
            ),
            const SizedBox(height: 16),
            FilterChip.elevated(
              avatar: const Icon(Icons.favorite_rounded),
              label: const Text('FilterChip'),
              onSelected: (bool value) {},
              onDeleted: () {},
            ),
          ],
        ),
      ),
    );
  }
}

Before

Not possible to add delete button

After

Screenshot 2023-10-16 at 17 56 51

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Oct 16, 2023
Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HansMuller HansMuller added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 23, 2023
@auto-submit auto-submit bot merged commit 6c3010e into flutter:master Oct 23, 2023
61 checks passed
@TahaTesser TahaTesser deleted the filter_chip_delete_button branch October 24, 2023 07:49
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 24, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 24, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 24, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 25, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 25, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 25, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FilterChip should have DeletableChipAttributes/trailing to match Material 3 spec.
2 participants