-
Notifications
You must be signed in to change notification settings - Fork 164
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
keyboardType, validator, label, searchFn, mutipleSelection + format + version + description #11
Conversation
Added 3 things to the README.md file: - Values of the `DropdownMenuItem` objects must be strings or implement the `toString()` method. - Clear button. - Assert unique value can be avoided.
Label and error returned by function as Widget: ``` validator: (value){return(value==null?Row( children: <Widget>[ Icon(Icons.error,color: Colors.red,size: 14,), SizedBox(width: 5,), Text("Mandatory",style: TextStyle(color: Colors.red,fontSize: 13),), ], ):null);}, label: (value){return(Row( children: <Widget>[ Icon(Icons.info,color: Colors.blueAccent,size: 14,), SizedBox(width: 5,), Text("Oil producer",style: TextStyle(color: Colors.blueAccent,fontSize: 13),), ], ));}, ``` ![image](https://user-images.githubusercontent.com/32125299/74223889-f6b4ed80-4cb7-11ea-972b-bd62fcef29d8.png) Or as strings: ``` validator: (value){return(value==null?"Mandatory":null);}, label: (value){return("Oil producer");}, ``` ![image](https://user-images.githubusercontent.com/32125299/74223999-311e8a80-4cb8-11ea-91a1-73f853277703.png) Possibility to set the keyboard type for searches as follows: ``` keyboardType: TextInputType.number, ``` ![image](https://user-images.githubusercontent.com/32125299/74224388-0a148880-4cb9-11ea-9fc3-82491474e44d.png)
Improved package description as suggested here: https://pub.dev/packages/searchable_dropdown#-analysis-tab- Increased version from 1.1.0 to 1.1.1
Label and error returned by function as Widget: ``` validator: (value){return(value==null?Row( children: <Widget>[ Icon(Icons.error,color: Colors.red,size: 14,), SizedBox(width: 5,), Text("Mandatory",style: TextStyle(color: Colors.red,fontSize: 13),), ], ):null);}, label: (value){return(Row( children: <Widget>[ Icon(Icons.info,color: Colors.blueAccent,size: 14,), SizedBox(width: 5,), Text("Oil producer",style: TextStyle(color: Colors.blueAccent,fontSize: 13),), ], ));}, ``` ![image](https://user-images.githubusercontent.com/32125299/74223889-f6b4ed80-4cb7-11ea-972b-bd62fcef29d8.png) Or as strings: ``` validator: (value){return(value==null?"Mandatory":null);}, label: (value){return("Oil producer");}, ``` ![image](https://user-images.githubusercontent.com/32125299/74223999-311e8a80-4cb8-11ea-91a1-73f853277703.png) Possibility to set the keyboard type for searches as follows: ``` keyboardType: TextInputType.number, ``` ![image](https://user-images.githubusercontent.com/32125299/74224388-0a148880-4cb9-11ea-9fc3-82491474e44d.png) Ran: ``` flutter format lib/searchable_dropdown.dart ``` As suggested here: https://pub.dev/packages/searchable_dropdown#-analysis-tab-
Added searchFn to README.md to let the user know how to expand the search to keywords separated by a space for example.
New `searchFn` lets the developer define the search function through which the list items are filtered. For example, the string typed by the user can be considered as keywords separated by spaces: ```dart searchFn: (String keyword, List<DropdownMenuItem<MyData>> items) { List<int> ret = List<int>(); if (keyword != null && items != null) { keyword.split(" ").forEach((k) { int i = 0; items.forEach((item) { if (keyword.isEmpty || (k.isNotEmpty && (item.value.toString().toLowerCase().contains(k.toLowerCase())))) { ret.add(i); } i++; }); }); } if(keyword.isEmpty){ ret = Iterable<int>.generate(items.length).toList(); } return (ret); }, ``` Here is an example of result: ![image](https://user-images.githubusercontent.com/32125299/74232473-29b3ad00-4cc9-11ea-94bd-fd4b64739e20.png)
Added multiple selection to README mentioning when a parameter has impact.
added multiple selection to pubspec.yaml
### Multiple selection Multiple selection is available through the `multipleSelection` parameter: ```dart multipleSelection: true, ``` ![image](https://user-images.githubusercontent.com/32125299/74260975-b75bc080-4cfa-11ea-92c9-89e0090493c7.png) This disables `onChanged` callback function. See below. There is a way to customize the display of the selected and unselected items through the `displayItemWhenMultiple` parameter function: ```dart displayItemWhenMultiple: (item,selected) { return (Row(children: [ selected ? Icon(Icons.check, color: Colors.green,) : Icon( Icons.check_box_outline_blank, color: Colors.grey,), SizedBox(width: 7), item ])); }, ``` ![image](https://user-images.githubusercontent.com/32125299/74260857-8a0f1280-4cfa-11ea-936c-167701c87021.png) The done button is displayed only when in multiple selection mode. It can be customized either by setting the String parameter `doneText` or by setting the function parameter `doneButtonFn`: ```dart doneText: "OK", ``` ![image](https://user-images.githubusercontent.com/32125299/74261413-816b0c00-4cfb-11ea-99c7-5df6ac463aa0.png) Or: ```dart doneButtonFn: (newContext){return FlatButton( onPressed: () { Navigator.pop(newContext); }, child: Text("I'm through"));}, ``` ![image](https://user-images.githubusercontent.com/32125299/74261685-e32b7600-4cfb-11ea-8290-6fb9a15176c2.png) The multiple items set by default can be set through the parameter `selectedItems` as follows: ```dart List<int> selectedItems = [1,3]; ... selectedItems: selectedItems, ``` Where the int values are the indexes of the selected items in the list of items. ![image](https://user-images.githubusercontent.com/32125299/74298875-47c1f180-4d4b-11ea-8451-8a584d9a7c29.png) Once the selection is done, the `selectedItems` list above is updated or the values can be retrieved through the `onChangedMultiple` function parameter: ```dart onChangedMultiple: (List<int> selectedIndexes){ selectedIndexes.forEach((item){ print("selected index: $item"); }); }, ``` The indexes of the selected items are sent to this callback function. Note that in the multiple selection case, the `onChanged` callback function is not called as the parameter type is not a list. The `validator` function can also be used in the multiple selection case: ```dart validator: (List<int>selectedIndexes){return(selectedIndexes==null||selectedIndexes.length==0?"Mandatory":null);}, ``` The `selectedValueWidgetFn` function can be used in the mutiple selection case the same way it is used in the single selection case: ```dart selectedValueWidgetFn: (value) => Padding( padding: EdgeInsets.fromLTRB(20, 20, 20, 20), child:Text( value.toString(), style: TextStyle(color:Colors.green), ) ), ``` The clear button works the same way in multiple and single cases.
Hello @icemanbsi , |
* demo app with a gallery as tabs or as a single page (change through a switch) * automated testing * continuous integration (CI) * continuous deployment (CD) * license is MIT * split constructors between single and multiple selection * comments on the constructors * selection can be done in a menu, not just a dialog box * solution to allow flexibility to provide a String, a Widget or a Function that returns either one of String or Widget for several components of the Widget * documentation * keyboard doesn't overlap dialog
Hello @icemanbsi , I fell I changed things a bit too much for a PR to make sense now. I hope you don't mind I closed it? Cheers. |
Hi @lcuis , |
Hello @icemanbsi , Thank you very much for the merge and the contributor proposal! This PR was against my master branch which changed significantly since the PR proposal. It contained many more changes than those listed in the description as this is a different plugin:
This has several consequences for the users:
This also has consequences for your repository:
I will try to correct the consequences for the users so that they are not affected and I will probably remove the automated testing, the CI and the CD. Please let me know if you have a different point of view. |
yes, I'm very aware of it. since I haven't published any update on flutter pub, I think it should be ok. |
Ok, thanks, I am working on the next PR to correct things for your plugin publication. |
Label and error returned by function as Widget:
Or as strings:
Possibility to set the keyboard type for searches as follows:
New
searchFn
lets the developer define the search function through which the list items are filtered. For example, the string typed by the user can be considered as keywords separated by spaces:Here is an example of result:
Multiple selection
Multiple selection is available through the
multipleSelection
parameter:This disables
onChanged
callback function. See below.There is a way to customize the display of the selected and unselected items through the
displayItemWhenMultiple
parameter function:The done button is displayed only when in multiple selection mode. It can be customized either by setting the String parameter
doneText
or by setting the function parameterdoneButtonFn
:Or:
The multiple items set by default can be set through the parameter
selectedItems
as follows:Where the int values are the indexes of the selected items in the list of items.
Once the selection is done, the
selectedItems
list above is updated or the values can be retrieved through theonChangedMultiple
function parameter:The indexes of the selected items are sent to this callback function. Note that in the multiple selection case, the
onChanged
callback function is not called as the parameter type is not a list.The
validator
function can also be used in the multiple selection case:The
selectedValueWidgetFn
function can be used in the mutiple selection case the same way it is used in the single selection case:The clear button works the same way in multiple and single cases.
Ran:
As suggested here:
https://pub.dev/packages/searchable_dropdown#-analysis-tab-
Improved package description as suggested here:
https://pub.dev/packages/searchable_dropdown#-analysis-tab-
Increased version from 1.1.0 to 1.1.1
Added to the README.md file:
DropdownMenuItem
objects must be strings or implement thetoString()
method.