-
Notifications
You must be signed in to change notification settings - Fork 91
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
Updating Items, not updating the dropdown. #156
Comments
@singgihmardianto please were you able to solve this issue? |
class InputMultiSelect<T extends Object> extends StatefulWidget {
const InputMultiSelect({
super.key,
this.items,
this.selectedItem,
this.onChange,
this.name,
});
final List<T>? items;
final List<T>? selectedItem;
final String? name;
final Function(List<T>? selected)? onChange;
@OverRide
State<InputMultiSelect> createState() => _InputMultiSelectState<T>();
}
class _InputMultiSelectState<T extends Object>
extends State<InputMultiSelect<T>> {
final MultiSelectController<T> controller = MultiSelectController();
@OverRide
void initState() {
super.initState();
}
@OverRide
void didUpdateWidget(InputMultiSelect<T> oldWidget) {
super.didUpdateWidget(oldWidget);
if (!listEquals(oldWidget.items, widget.items)) {
controller.setItems(widget.items!
.map((item) => DropdownItem(
label: item.toString(),
value: item,
selected: widget.selectedItem!.contains(item)))
.toList());
}
}
@OverRide
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 12, 12),
child: SizedBox.fromSize(
size: const Size.fromHeight(39),
child: MultiDropdown<T>(
controller: controller,
items: widget.items!
.map((item) => DropdownItem(
label: item.toString(),
value: item,
selected: widget.selectedItem!.contains(item)))
.toList(),
onSelectionChange: (selected) => widget.onChange!(selected),
searchEnabled: true,
),
),
);
}
}
…On Tue, Nov 19, 2024 at 3:24 PM Kehinde Alabi ***@***.***> wrote:
@singgihmardianto <https://github.com/singgihmardianto> please were you
able to solve this issue?
—
Reply to this email directly, view it on GitHub
<#156 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEF7OWXGNJTJ2OR465S2JN32BK4P3AVCNFSM6AAAAABOGPADMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOBUGY3TSNJUGE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there, great plugin here! Basically, so thankful with this plugin. But I am facing an issue when I updating the items parameters.
First, I have a component called
InputMultiselect
that wrap this widget. Something like thisThen I will use in it my form simply just like this:
The problem is whenever I update
_categoryOptions
usingsetState()
the dropdown will not update the items. I already do a trace to look how the plugin works, so may be I can get a hot fix for my issue.I debug
widget.items
on line 383 the items is updated.But here on line 433, it's uses
_dropdownController.items
instead ofwidget.items
There I assume may be the reason why the dropdown it's not updating.
Any idea how to do a hot fix here? Or Am I missed something? Thanks!
The text was updated successfully, but these errors were encountered: