flutter-form-builder-ecosystem / form_builder_extra_fields

Additional ready-made form input fields for flutter_form_builder package
https://pub.dev/packages/form_builder_extra_fields
BSD 3-Clause "New" or "Revised" License
28 stars 47 forks source link

[FormBuilderSearchableDropdown]: Another exception was thrown: 'package:form_builder_extra_fields/src/fields/form_builder_searchable_dropdown.dart': Failed assertion: line 128 pos 16: 'T == String || compareFn != null': is not true. #96

Open dedyksuntoro opened 9 months ago

dedyksuntoro commented 9 months ago

Is there an existing issue for this?

Package/Plugin version

10.1.0

Platforms

Flutter doctor

Flutter doctor ``` Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.13.9, on Microsoft Windows [Version 10.0.22621.2283], locale en-ID) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [√] Chrome - develop for the web [√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.1.0) [√] Android Studio (version 2022.3) [√] VS Code (version 1.84.2) [√] Connected device (4 available) [√] Network resources • No issues found! ```

Minimal code example

Code sample ```dart List selectBan = []; _futureSelectSerahTerimaKendaraanListBan = _apiDatabase.geSelectSerahTerimaKendaraanListBan(); _futureSelectSerahTerimaKendaraanListBan.then((value) { setState(() { selectBan = value; }); }); FormBuilderSearchableDropdown( name: 'al', decoration: InputDecoration( label: Text('AL'), border: OutlineInputBorder(), ), items: selectBan .map( (e) => DropdownMenuItem( value: e.id, child: Text( e.sparepart.toString(), ), ), ) .toList(), onChanged: (value) {}, ), ```

Current Behavior

Error Message: Another exception was thrown: 'package:form_builder_extra_fields/src/fields/form_builder_searchable_dropdown.dart': Failed assertion: line 128 pos 16: 'T == String || compareFn != null': is not true.

Expected Behavior

Maybe this can be fixed soon

Steps To Reproduce

-

Aditional information

No response

enjat26 commented 2 months ago

i think this issue because condition (T == String || compareFn != null) not met, you can add or add compareFn: (item1, item2) => true,

like this :

Widget _masterCheckPoint() { return FormBuilderSearchableDropdown( name: 'mstr_id', decoration: const InputDecoration( hintText: 'Check Point', label: Text('Check Point'), ), validator: FormBuilderValidators.compose([ FormBuilderValidators.required(), ]), asyncItems: (String? filter) => _controller.getMasterCheckPoint(filter), compareFn: (item1, item2) => true, popupProps: const PopupProps.menu( showSearchBox: true, ), ); }

jesse-shaw-egeo commented 2 months ago

This is not a bug, either your generic type has to be a string, or you have to implement the custom compare function.