Skip to content
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

[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
2 of 7 tasks
dedyksuntoro opened this issue Nov 30, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@dedyksuntoro
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Package/Plugin version

10.1.0

Platforms

  • Android
  • iOS
  • Linux
  • MacOS
  • Web
  • Windows

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
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

@dedyksuntoro dedyksuntoro added the bug Something isn't working label Nov 30, 2023
@dedyksuntoro dedyksuntoro changed the title [Field name or General]: <title> [Field name or General]: 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. Nov 30, 2023
@dedyksuntoro dedyksuntoro changed the title [Field name or General]: 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. [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. Nov 30, 2023
@enjat26
Copy link

enjat26 commented Jun 28, 2024

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants