Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Missing features #5

Open
3 tasks
ride4sun opened this issue Oct 25, 2017 · 11 comments
Open
3 tasks

Missing features #5

ride4sun opened this issue Oct 25, 2017 · 11 comments

Comments

@ride4sun
Copy link
Contributor

ride4sun commented Oct 25, 2017

I would like to see these features:

  • callback called on any text change when the search app is visible
  • close button instead of the back button is more common to dismiss the appbar.
    For user it appears like that navigation never change.
  • when the searchBar gets dismissed the last update should clear the search text (maybe that can be handled in the hosting code but it would be more elegant in the searchbar) This could be activated/deactivated with a bool in the constructor
@ride4sun
Copy link
Contributor Author

I can provide them if you like

@ArcticZeroo
Copy link
Owner

If you need to listen for text changes, I think the best way is to use a TextEditingController and call addListener to listen for changes in text values.

Feel free to implement the other two, but close/back button should probably be an option you can set in the constructor (it should default to back just for backwards compatibility).

@ride4sun
Copy link
Contributor Author

Sounds good - I will provide a pull request asap

@ArcticZeroo
Copy link
Owner

Just to clarify, the TextEditingController can be passed as an argument to the constructor of SearchBar currently (as controller)

@ride4sun
Copy link
Contributor Author

Do you mind if I create a statefull widget out of it because the clear button has a state and is only shown when the user entered text. I did see the TextEditController, I agree with ur last statement. The function of the back button stays the same. All that should be compatible with the old paradigm.

@ride4sun
Copy link
Contributor Author

I think I dont need no statefull widget - forgot that setState is required

ride4sun added a commit to ride4sun/flutter-search-bar that referenced this issue Oct 26, 2017
* Added clear button to clear the search term
* Added configuration to hide clear button showClearTextButton
* Added bool hideSearchBoxDevider
* Added popParentOnBackButton to navigate back on back buttonnot just out of the SearchBar
@rodydavis
Copy link

@ride4sun here is what I did to get those feature. https://gist.github.com/AppleEducate/932e9426b53468882717cf0f1b463a72

@ArcticZeroo
Copy link
Owner

@AppleEducate thanks! I'll look into adding it into master sometime in the next few days.

Personally, I would recommend setting onChanged to a new ValueNotifier rather than allowing the user to set it -- the cost of holding a ValueNotifier is pretty tiny, and eliminates what will likely be a common source of user error.

Is this module really super useful though since Flutter has a first-class search widget now?

@rodydavis
Copy link

rodydavis commented Jul 30, 2018

@ArcticZeroo I was not aware of the first class widget? I have been using this custom class since flutter beta 2. I had to pass the onChanged because I am calling an api for search results.

are you talking about material_search ?

I also use this custom search I built:
https://gist.github.com/AppleEducate/224ccdbae1d18bf41d7cd9cc85c426a2

@ArcticZeroo
Copy link
Owner

ArcticZeroo commented Jul 30, 2018

@AppleEducate here's some info on the first class widget (I don't see any docs for it):

flutter/flutter#17629

https://github.com/flutter/flutter/blob/master/examples/flutter_gallery/lib/demo/material/search_demo.dart

Seems a bit over-involved to me, but it's not third party I suppose 🤷‍♂️

edit: It looks like this isn't quite the same as the one this third party module does. The first class widget is more of a material_search type widget from what I can tell. So I guess it does make sense to continue development on this after all

@rodydavis
Copy link

I think thats why I didn't know about it. I usually go off the docs. Thanks! ill check it out 👍🏻

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants