ArcticZeroo / flutter-search-bar

(mostly) Automatic search-enabled appBar for flutter
BSD 3-Clause "New" or "Revised" License
266 stars 69 forks source link

Does not support text input number #32

Closed edutrul closed 3 years ago

edutrul commented 5 years ago

Hi! (first of all great work on flutter search bar)

ISSUE

KeyboardType only supports text though what about the cases when we have to deal with numbers? in my case I need to search by number

image

and I see in code keyboardType: TextInputType.text,

should be

keyboardType: TextInputType.number,

though this would be have to be an optional settings

TECHNICAL APPROACH

@todo

NOTES

@todo

gozeloglu commented 3 years ago

Hi @ArcticZeroo ,

I can work on that issue. My approach is adding a parameter like numberType which default value is false and check on https://github.com/ArcticZeroo/flutter-search-bar/blob/499bbe6730075d44051bad187597c8e05704afaa/lib/src/flutter_search_bar_base.dart#L152 line and if developer passes true for that parameter, it shows up number. numberType name can be changed by good name, of course. What do you think about my approach?

ArcticZeroo commented 3 years ago

Hi @ArcticZeroo ,

I can work on that issue. My approach is adding a parameter like numberType which default value is false and check on

https://github.com/ArcticZeroo/flutter-search-bar/blob/499bbe6730075d44051bad187597c8e05704afaa/lib/src/flutter_search_bar_base.dart#L152

line and if developer passes true for that parameter, it shows up number. numberType name can be changed by good name, of course. What do you think about my approach?

Hey @gozeloglu, I think it makes the most sense here to add a parameter which allows the developer to pass any text input type rather than 'hardcoding' it to be only number or not. This way we don't need a boolean option for every single future text input type that may be desired in the future.

gozeloglu commented 3 years ago

Hi @ArcticZeroo , I can work on that issue. My approach is adding a parameter like numberType which default value is false and check on https://github.com/ArcticZeroo/flutter-search-bar/blob/499bbe6730075d44051bad187597c8e05704afaa/lib/src/flutter_search_bar_base.dart#L152

line and if developer passes true for that parameter, it shows up number. numberType name can be changed by good name, of course. What do you think about my approach?

Hey @gozeloglu, I think it makes the most sense here to add a parameter which allows the developer to pass any text input type rather than 'hardcoding' it to be only number or not. This way we don't need a boolean option for every single future text input type that may be desired in the future.

Hmm, you mean that I should add a parameter in TextInputType type. So, the developer can call the function like SearchBar(TextInputType.text, ...) if he wants to create a text keyboard and calls the function like SearchBar(TextInputType.number,...) if he wants to create a number keyboard. If I understood correctly, what should be the default value of that parameter? I think text is appropriate for this.

ArcticZeroo commented 3 years ago

Hmm, you mean that I should add a parameter in TextInputType type. So, the developer can call the function like SearchBar(TextInputType.text, ...) if he wants to create a text keyboard and calls the function like SearchBar(TextInputType.number,...) if he wants to create a number keyboard. If I understood correctly, what should be the default value of that parameter? I think text is appropriate for this.

Yeah, that is pretty much what I am suggesting. Though it should not be a positional parameter, it should be named like everything else (e.g. SearchBar(keyboardType: TextInputType.text)). The default value also must be text so that we don't break backwards compatibility

gozeloglu commented 3 years ago

Hmm, you mean that I should add a parameter in TextInputType type. So, the developer can call the function like SearchBar(TextInputType.text, ...) if he wants to create a text keyboard and calls the function like SearchBar(TextInputType.number,...) if he wants to create a number keyboard. If I understood correctly, what should be the default value of that parameter? I think text is appropriate for this.

Yeah, that is pretty much what I am suggesting. Though it should not be a positional parameter, it should be named like everything else (e.g. SearchBar(keyboardType: TextInputType.text)). The default value also must be text so that we don't break backwards compatibility

I made changes in ab81ae7

gozeloglu commented 3 years ago

I think this issue can be closed. It is fixed in https://github.com/ArcticZeroo/flutter-search-bar/pull/41 @ArcticZeroo @edutrul