salim-lachdhaf / dropdown_search

Simple and robust Dropdown with item search feature, making it possible to use an offline item list or filtering URL for easy customization.
MIT License
346 stars 334 forks source link

How to call the validator on a button click ? #707

Closed PKReejesh closed 1 week ago

PKReejesh commented 1 week ago

I wish to call the validator on a button click and highlight the error, is that possible with this widget ?

I have seen the autoValidateMode mode, but is there a manual way to trigger the validate method and show the error ?

salim-lachdhaf commented 1 week ago

Yes you can, use AutovalidateMode.disabled and validate your form in demand by calling formKey.validate() Where formKey is GlobalKey to be assigned to your Form .

don't forget to implement validator for your DropdownSearch

Take a look here .

Please don't hesitate to like the repo and the lib if it's helpful for you.