-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Editable items list within a menu #63
Comments
Hello @Macacoazul01 , Thanks for raising this issue. I was able to integrate your example to my example file without the 1.1 Click on dropdown button while menu is opened doesn't close menu. I confirm this is a bug in 2.1 When adding an item, the list in the menu doesn't refresh. I witness this behavior. This would be solved if next point is solved.
Sorry for the inconvenience and thanks for reporting! I will post again here when I have something new regarding these points. |
Some problems seem related to the searchfn parameter + custom dropdown cells combo. |
gonna fork your package and try to help |
The delete problem: When i didn't change the searchfn, line 1996 is called after a deletion in the list. With the search function, line 1981 was called only when the list opens and not after the deletion too. |
a convenient way to solve 1.2, 2.1 and 2.2 is to call something like These errors aren't present on your example because you pop the dialog after adding the new item, so there's no need to 'refresh the list on the dialog'.
Your sample won't refresh the list also. |
this happens with and without the custom |
Thanks a lot for your help @Macacoazul01 . I hope to come back to you on this soon. |
* Bug 63 1.1 Click on dropdown button while menu is opened doesn't close menu. Thanks @Macacoazul01 #63 * Enhancement 63 1.2 Pop menu from onChanged. Thanks @Macacoazul01 #63 * Enhancement 63 2.2 Pop menu from updateParent. Thanks @Macacoazul01 #63 * Bug 63 3. Delete last item from menu causes index error. Thanks @Macacoazul01 #63
Here is the content of version 2.0.17 deployed on pub.dev
I had to change your example in the following file: I hope the adaptations and the outcome will be acceptable to you. |
Thank you. Gonna look! |
There are just some things that aren't problems but a little unconfortable to the final user (using the final main.dart): 1- when i delete an item the list closes but besides this, it's perfect |
Hi @Macacoazul01 , Thanks for your feedback! I hope we can find solutions for these issues. |
To solve second, could be a new default value to this new pop function
|
Another option, we could have two states avaliable: 1- the dropdown state 2- the dialog/menu state I don't know if this idea helps solving this problem, just giving you more ideas |
More on error 2: The When i click on |
Hi @Macacoazul01 , Thanks for your patience. The following example solves the 2 latest issues in my tests: SearchChoices.single(
items: editableItems,
value: selectedValueSingleMenuEditableItems,
hint: "Select one",
searchHint: "Select one",
disabledHint: (Function updateParent) {
return (TextButton(
onPressed: () {
addItemDialog().then((value) async {
updateParent(value);
});
},
child: Text("No choice, click to add one"),
));
},
closeButton:
(String? value, BuildContext closeContext, Function updateParent) {
return (editableItems.length >= 100
? "Close"
: TextButton(
onPressed: () {
addItemDialog().then((value) async {
if (value != null &&
editableItems.indexWhere(
(element) => element.value == value) !=
-1) {
updateParent(value,true);
}
});
},
child: Text("Add and select item"),
));
},
onChanged: (String? value, Function? pop) {
setState(() {
if (!(value is NotGiven)) {
selectedValueSingleMenuEditableItems = value;
}
});
if (pop != null&&!(value is NotGiven)&&value!=null) {
pop();
}
},
displayItem: (DropdownMenuItem item, selected, Function updateParent) {
bool deleteRequested = false;
return (GestureDetector(
onTapUp: (tap) {
Future.delayed(Duration(milliseconds: 300)).whenComplete(() {
if (!deleteRequested) {
updateParent(item.value, true);
}
});
},
child: (Row(children: [
selected
? Icon(
Icons.check,
color: Colors.green,
)
: Icon(
Icons.check_box_outline_blank,
color: Colors.transparent,
),
SizedBox(width: 7),
Expanded(
child: item,
),
IconButton(
icon: Icon(
Icons.delete,
color: Colors.red,
),
onPressed: () {
deleteRequested = true;
editableItems.removeWhere((element) => item == element);
updateParent(selected ? null : NotGiven(), false);
setState(() {});
},
),
])),
));
} Sorry, I focused on this example as I would like to use it in the example project. The The |
on my tests the gesture detector isnt doing nothing. i've put two prints inside the code and none of them were executed:
|
Maybe, the GestureDetector has a different behavior on web? |
It works for me on mobile, though, I only tested on Android for now. |
Using the https://stackoverflow.com/questions/60335245/flutter-for-web-gesturedetector-around-raisedbutton
|
fixed:
|
Excellent, thanks a lot. I will update the example accordingly as soon as I can! |
…em selection issue on web because gesture detector doesn't have the same behavior. Thanks @Macacoazul01 !
Gonna close this issue as all of the items were solved. |
Thanks to you @Macacoazul01 ! |
Hi @lcuis and thanks for developing search choices.
Using your samples i was able to create this widget for my custom class
Produto
:without anything added:
with one item added:
But i'm having some problems that i couldn't solve. Here are them:
1- With the list open, if i click on the dropdown, the list doesnt close. The same thing happens if i click on the already selected
Produto
or another one item of the list. If i click on another, the selected one changes at least.2- When i click on 'adicionar novo produto' to add another item, the item is added but the list doesnt refresh, only the selected item on the dropdown, also the list isn't closing by itself like your
Single dialog editable items
:3 - If i have only one item on the list and i try to delete it, there is this error. In your sample it doesn't happened:
4- If i have more than one item, the list doesn't refresh like your sample.
(both 3 and 4 seem related)
package version: search_choices: ^2.0.16
sample project:
search.zip
I don't know if these errors are from the package or the code (probably the latter).
Can you please help me?
The text was updated successfully, but these errors were encountered: