-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Clearing a selected item #83
Comments
i'm having this problem too, is there any update on this |
Hey @Ivan-Wabuyobo @rymesaint Thanks for your concern. |
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: 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, Thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The text was updated successfully, but these errors were encountered: