Skip to content

Added filter callback on dropdown menu #143939

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

Merged

Conversation

dacianf
Copy link
Contributor

@dacianf dacianf commented Feb 22, 2024

I added a callback on DropDown Menu for filtering options. I needed this feature because I wanted to filtered data using a custom way and that was not possible. For searching there was already a callback that helped, but none for filtering.

Pre-launch Checklist

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

@dacianf dacianf force-pushed the feature/add-filter-callback-on-dropdown branch from 8aa47ee to 4f34899 Compare February 22, 2024 15:44
@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Feb 22, 2024
@dacianf dacianf force-pushed the feature/add-filter-callback-on-dropdown branch 2 times, most recently from 9b9a75c to 3ed4b29 Compare February 26, 2024 15:34
@dacianf dacianf force-pushed the feature/add-filter-callback-on-dropdown branch 2 times, most recently from 6201d0d to d61b4e1 Compare March 11, 2024 14:48
@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@dacianf dacianf force-pushed the feature/add-filter-callback-on-dropdown branch from d61b4e1 to 4e6c9b0 Compare April 12, 2024 14:01
@dacianf
Copy link
Contributor Author

dacianf commented Apr 12, 2024

@QuncCccccc any idea when you can look over this PR?

@QuncCccccc
Copy link
Contributor

@QuncCccccc any idea when you can look over this PR?

Hi! Sorry for the late response! Overall this is a reasonable feature, will take a look very soon!

@dacianf dacianf force-pushed the feature/add-filter-callback-on-dropdown branch 5 times, most recently from fd6e724 to 7c621a4 Compare April 16, 2024 16:00
@dacianf dacianf force-pushed the feature/add-filter-callback-on-dropdown branch from 7c621a4 to 6fe0afd Compare April 23, 2024 13:50
@dacianf dacianf requested a review from QuncCccccc April 25, 2024 09:11
@dacianf dacianf force-pushed the feature/add-filter-callback-on-dropdown branch 2 times, most recently from e16bd71 to d6fd5aa Compare April 29, 2024 21:07
@dacianf
Copy link
Contributor Author

dacianf commented Apr 29, 2024

@QuncCccccc can you take one more look here, please?

@dacianf dacianf force-pushed the feature/add-filter-callback-on-dropdown branch from d6fd5aa to d0e6777 Compare May 2, 2024 13:12
@dacianf
Copy link
Contributor Author

dacianf commented May 2, 2024

@QuncCccccc any updates?

@dacianf dacianf force-pushed the feature/add-filter-callback-on-dropdown branch from d0e6777 to 815379e Compare May 14, 2024 21:03
@dacianf
Copy link
Contributor Author

dacianf commented May 14, 2024

@QuncCccccc are you still around? @HansMuller Should I contact someone else?

@dacianf dacianf force-pushed the feature/add-filter-callback-on-dropdown branch from 815379e to eef9a56 Compare May 15, 2024 09:23
Copy link
Contributor

@QuncCccccc QuncCccccc left a comment

Choose a reason for hiding this comment

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

Thanks for your patience! Just left some comments below. After fixing these, we should good to go!

@dacianf dacianf force-pushed the feature/add-filter-callback-on-dropdown branch from eef9a56 to ec9eec8 Compare May 21, 2024 06:18
@QuncCccccc
Copy link
Contributor

Ah I didn't realize there was already enableSearch and searchCallback. I don't want to overly complicate things then. @QuncCccccc did you originally write enableSearch and serachCallback? Do you think it's worth it to migrate all of them or just keep everything as-is?

I think we can just keep it as-is for now, but at the same time we might want to add an assertion to make sure when filterCallback is not null, enableFilter must has been set to true, something like assert(filterCallback == null || filterCallback != null && enableFilter == true). Thanks @justinmc for your suggestions!

@dacianf dacianf requested a review from victorsanni May 31, 2024 17:12
@dacianf
Copy link
Contributor Author

dacianf commented May 31, 2024

@QuncCccccc I added it. Wasn't sure if I needed to add a comment there or not.

@dacianf dacianf force-pushed the feature/add-filter-callback-on-dropdown branch from 51fb0b2 to 4632fe9 Compare May 31, 2024 17:32
Copy link
Contributor

@QuncCccccc QuncCccccc left a comment

Choose a reason for hiding this comment

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

LGTM with some suggestions below.

Just noticed I didn't click Approve last time. I will ask the second review when the comments are fixed:)! Thanks again for the contribution!

@dacianf
Copy link
Contributor Author

dacianf commented May 31, 2024

LGTM with some suggestions below.

Just noticed I didn't click Approve last time. I will ask the second review when the comments are fixed:)! Thanks again for the contribution!

No worries @QuncCccccc ! I fixed the comments!

Thank you too for helping me getting it done!

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

@dacianf I wonder what you think about this comment about possibly setting a default value for filterCallback: https://github.com/flutter/flutter/pull/143939/files#r1621190671

Otherwise everything else is nits and this PR looks good.

@dacianf dacianf force-pushed the feature/add-filter-callback-on-dropdown branch from ceb5087 to 32c5675 Compare June 1, 2024 08:08
@dacianf dacianf requested a review from justinmc June 2, 2024 19:23
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

LGTM 👍 . Thanks for answering all of my questions and making those fixes!

@@ -162,6 +168,7 @@ class DropdownMenu<T> extends StatefulWidget {
this.focusNode,
this.requestFocusOnTap,
this.expandedInsets,
this.filterCallback,
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok agreed, it makes sense to do this the same way as searchCallback for now.

@justinmc justinmc merged commit a92318d into flutter:master Jun 3, 2024
71 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 3, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 3, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 3, 2024
@dacianf dacianf deleted the feature/add-filter-callback-on-dropdown branch June 4, 2024 07:22
hello-coder-xu pushed a commit to hello-coder-xu/flutter that referenced this pull request Jun 4, 2024
…pdate

* master: (168 commits)
  Fix the scrolling layout deviation of `CupertinoActionSheet` (flutter#149439)
  Roll Flutter Engine from 60a7bb2353b6 to a6aa5d826649 (2 revisions) (flutter#149627)
  Roll Flutter Engine from ea72558be758 to 60a7bb2353b6 (2 revisions) (flutter#149623)
  Place `flutter_gpu` in the package cache. (flutter#149299)
  Switch to triage-* labels for platform package triage (flutter#149614)
  Roll pub packages (flutter#149617)
  Fixes multi line textfield hint text gets ellipsized (flutter#148423)
  Support failures-only and silent reporters in `flutter test` (flutter#148739)
  [CupertinoActionSheet] Fix overflow of the overscroll section when the user scrolls far (flutter#149542)
  Fix InputDecorator.prefixIcon color when disabled (flutter#149595)
  Added filter callback on dropdown menu (flutter#143939)
  update generated localized message files in the stocks test app (flutter#148741)
  Add a simplified SimpleCascadingMenuApp example (flutter#149147)
  Reland "Prevent LayoutBuilder from rebuilding more than once (flutter#147856)" (flutter#149303)
  Move some benchmarks from MotoG4 to Mokey (flutter#149567)
  Roll Packages from d8e8e8c to 11e192a (2 revisions) (flutter#149596)
  Cleanup triage reports from docs/ (flutter#149545)
  Roll Flutter Engine from d81edf635a9f to ea72558be758 (1 revision) (flutter#149590)
  Roll Flutter Engine from b0f4d7459708 to d81edf635a9f (1 revision) (flutter#149468)
  Roll Flutter Engine from 40b868efcc46 to b0f4d7459708 (1 revision) (flutter#149467)
  ...
hello-coder-xu added a commit to hello-coder-xu/flutter that referenced this pull request Jun 6, 2024
…pdate

* master: (168 commits)
  Fix the scrolling layout deviation of `CupertinoActionSheet` (flutter#149439)
  Roll Flutter Engine from 60a7bb2353b6 to a6aa5d826649 (2 revisions) (flutter#149627)
  Roll Flutter Engine from ea72558be758 to 60a7bb2353b6 (2 revisions) (flutter#149623)
  Place `flutter_gpu` in the package cache. (flutter#149299)
  Switch to triage-* labels for platform package triage (flutter#149614)
  Roll pub packages (flutter#149617)
  Fixes multi line textfield hint text gets ellipsized (flutter#148423)
  Support failures-only and silent reporters in `flutter test` (flutter#148739)
  [CupertinoActionSheet] Fix overflow of the overscroll section when the user scrolls far (flutter#149542)
  Fix InputDecorator.prefixIcon color when disabled (flutter#149595)
  Added filter callback on dropdown menu (flutter#143939)
  update generated localized message files in the stocks test app (flutter#148741)
  Add a simplified SimpleCascadingMenuApp example (flutter#149147)
  Reland "Prevent LayoutBuilder from rebuilding more than once (flutter#147856)" (flutter#149303)
  Move some benchmarks from MotoG4 to Mokey (flutter#149567)
  Roll Packages from d8e8e8c to 11e192a (2 revisions) (flutter#149596)
  Cleanup triage reports from docs/ (flutter#149545)
  Roll Flutter Engine from d81edf635a9f to ea72558be758 (1 revision) (flutter#149590)
  Roll Flutter Engine from b0f4d7459708 to d81edf635a9f (1 revision) (flutter#149468)
  Roll Flutter Engine from 40b868efcc46 to b0f4d7459708 (1 revision) (flutter#149467)
  ...
hello-coder-xu added a commit to hello-coder-xu/flutter that referenced this pull request Jun 9, 2024
…pdate

* master: (181 commits)
  Fix the scrolling layout deviation of `CupertinoActionSheet` (flutter#149439)
  Roll Flutter Engine from 60a7bb2353b6 to a6aa5d826649 (2 revisions) (flutter#149627)
  Roll Flutter Engine from ea72558be758 to 60a7bb2353b6 (2 revisions) (flutter#149623)
  Place `flutter_gpu` in the package cache. (flutter#149299)
  Switch to triage-* labels for platform package triage (flutter#149614)
  Roll pub packages (flutter#149617)
  Fixes multi line textfield hint text gets ellipsized (flutter#148423)
  Support failures-only and silent reporters in `flutter test` (flutter#148739)
  [CupertinoActionSheet] Fix overflow of the overscroll section when the user scrolls far (flutter#149542)
  Fix InputDecorator.prefixIcon color when disabled (flutter#149595)
  Added filter callback on dropdown menu (flutter#143939)
  update generated localized message files in the stocks test app (flutter#148741)
  Add a simplified SimpleCascadingMenuApp example (flutter#149147)
  Reland "Prevent LayoutBuilder from rebuilding more than once (flutter#147856)" (flutter#149303)
  Move some benchmarks from MotoG4 to Mokey (flutter#149567)
  Roll Packages from d8e8e8c to 11e192a (2 revisions) (flutter#149596)
  Cleanup triage reports from docs/ (flutter#149545)
  Roll Flutter Engine from d81edf635a9f to ea72558be758 (1 revision) (flutter#149590)
  Roll Flutter Engine from b0f4d7459708 to d81edf635a9f (1 revision) (flutter#149468)
  Roll Flutter Engine from 40b868efcc46 to b0f4d7459708 (1 revision) (flutter#149467)
  ...
hello-coder-xu added a commit to hello-coder-xu/flutter that referenced this pull request Jun 11, 2024
* master: (181 commits)
  Fix the scrolling layout deviation of `CupertinoActionSheet` (flutter#149439)
  Roll Flutter Engine from 60a7bb2353b6 to a6aa5d826649 (2 revisions) (flutter#149627)
  Roll Flutter Engine from ea72558be758 to 60a7bb2353b6 (2 revisions) (flutter#149623)
  Place `flutter_gpu` in the package cache. (flutter#149299)
  Switch to triage-* labels for platform package triage (flutter#149614)
  Roll pub packages (flutter#149617)
  Fixes multi line textfield hint text gets ellipsized (flutter#148423)
  Support failures-only and silent reporters in `flutter test` (flutter#148739)
  [CupertinoActionSheet] Fix overflow of the overscroll section when the user scrolls far (flutter#149542)
  Fix InputDecorator.prefixIcon color when disabled (flutter#149595)
  Added filter callback on dropdown menu (flutter#143939)
  update generated localized message files in the stocks test app (flutter#148741)
  Add a simplified SimpleCascadingMenuApp example (flutter#149147)
  Reland "Prevent LayoutBuilder from rebuilding more than once (flutter#147856)" (flutter#149303)
  Move some benchmarks from MotoG4 to Mokey (flutter#149567)
  Roll Packages from d8e8e8c to 11e192a (2 revisions) (flutter#149596)
  Cleanup triage reports from docs/ (flutter#149545)
  Roll Flutter Engine from d81edf635a9f to ea72558be758 (1 revision) (flutter#149590)
  Roll Flutter Engine from b0f4d7459708 to d81edf635a9f (1 revision) (flutter#149468)
  Roll Flutter Engine from 40b868efcc46 to b0f4d7459708 (1 revision) (flutter#149467)
  ...
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. will affect goldens Changes to golden files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants