Open Ivan-Wabuyobo opened 4 months ago
i'm having this problem too, is there any update on this
Hey @Ivan-Wabuyobo @rymesaint Thanks for your concern. Please share the code so I can look why this issue is occurring!
I therefore need a button to remove the value that was chosen. How can I do this?
CustomDropdown(
items: _statuses,
headerBuilder: (context, selectedItem, enabled) =>
selectedItem.child,
listItemBuilder: (context, item, isSelected, onItemSelect) =>
item.child,
initialItem: _statuses.firstWhereOrNull(
(element) => element.value == _status.value,
),
hintText: 'Status',
onChanged: _changeStatus,
),
Try this code. Package version: 3.1.1
const List<String> _list = [
'Developer',
'Designer',
'Consultant',
'Student',
];
class ControllerCustomDropdown extends StatefulWidget {
const ControllerCustomDropdown({Key? key}) : super(key: key);
@override
State<ControllerCustomDropdown> createState() =>
_ControllerCustomDropdownState();
}
class _ControllerCustomDropdownState extends State<ControllerCustomDropdown> {
final controller = SingleSelectController<String>(null);
@override
Widget build(BuildContext context) {
return Column(
children: [
CustomDropdown(
controller: controller,
items: _list,
onChanged: (value) {
log('onChanged value: $value');
},
),
ElevatedButton(
onPressed: () {
controller.clear();
},
child: const Text('Clear'),
),
],
);
}
}
Hello, I think should be a feature of the component as it seems something very used.
Thanks
How do I clear an item that i have selected. I have to tried using the method clear() provided by the controller but it doesn't seem to come.