lcuis / search_choices

Widget to let the user search through a keyword string typed on a customizable keyboard in a single or multiple choices list presented as a dropdown in a dialog box or a menu.
MIT License
51 stars 42 forks source link

Error 'fieldDecoration == null || validator == null': use either validator or fieldDecoration) #92

Closed willhhf closed 1 year ago

willhhf commented 1 year ago

There is an error when use fieldDecoration and validator together, but why they are related and how can we decorate layour and use validator together?

Exception has occurred. _AssertionError ('package:search_choices/search_choices.dart': Failed assertion: line 1105 pos 16: 'fieldDecoration == null || validator == null': use either validator or fieldDecoration)

my code:

SearchChoices.single( //underline: const Divider(), items: items, value: value, style: Theme.of(context).textTheme.displaySmall, fieldDecoration: BoxDecoration( color: Colors.grey.shade200, shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(5), border: Border.all( color: Colors.blueGrey, width: 3, style: BorderStyle.solid, )), hint: hint, searchHint: searchHint, onClear: onClear, onChanged: onChanged, isExpanded: true, validator: validator, );

lcuis commented 1 year ago

Hello @willhhf ,

Thanks a lot for your question.

I don't see any other reason than an historical one. I tried removing this assertion and running an example with both validator and fieldDecoration and it ran with no issue.

I removed the assertion and will publish a new version as soon as possible to pub.dev . Before that, I must run the automated integration tests.

In the meanwhile, you can use the latest GitHub repository code with the following in your pubspec.yaml file:

  search_choices:
    git:
      url: https://github.com/lcuis/search_choices.git
willhhf commented 1 year ago

Hi Lcuis,

Thanks for your prompt reply.

The fixed version run well on my code.

lcuis commented 1 year ago

Excellent, thanks a lot for the confirmation!