Flutter dropdown_button2 searching item.child doesn't work in release mode but in debug mode run sucessfuly

37 views Asked by At

I have a problem with this package dropdown_button2: ^2.3.9 its about searching DropdownItem child contain widget text then converted toString().contains() work successfuly in debug mode but doesn't work in release mode. Anyone can help ?

DropdownButton2(
        isExpanded: true,
        hint: Text(
          'Pilih Pasien',
          style: TextStyle(
            fontSize: 14,
            color: Theme.of(context).hintColor,
          ),
        ),
        items: anggota
            .map((item) => DropdownMenuItem<String>(
                  value: item['id'],
                  child: Text(
                    item['name'],
                    style: const TextStyle(
                      fontSize: 14,
                    ),
                  ),
                ))
            .toList(),
        value: selectedAnggotaController,
        onChanged: (value) {
          setState(() {
            selectedAnggotaController = value as String;
            nomorRm = selectedAnggotaController;
            selectedPoliController = null;
            selectedDokterController = null;
            selectedPayorController = null;
            isHideDokter = true;
            isHidePayor = true;
            payor = [];
            _checkField();
          });
        },
        dropdownStyleData: const DropdownStyleData(
          maxHeight: 300,
        ),
        menuItemStyleData: const MenuItemStyleData(
          height: 40,
        ),
        dropdownSearchData: DropdownSearchData(
          searchController: searchPasien,
          searchInnerWidgetHeight: 70,
          searchInnerWidget: Container(
            height: 70,
            padding: const EdgeInsets.only(
              top: 8,
              bottom: 4,
              right: 8,
              left: 8,
            ),
            child: TextFormField(
              expands: true,
              maxLines: null,
              controller: searchPasien,
              decoration: InputDecoration(
                isDense: true,
                contentPadding:
                    const EdgeInsets.symmetric(
                  horizontal: 10,
                  vertical: 8,
                ),
                hintText: 'Find data...',
                hintStyle:
                    const TextStyle(fontSize: 12),
                border: OutlineInputBorder(
                  borderRadius:
                      BorderRadius.circular(8),
                ),
              ),
            ),
          ),
          searchMatchFn: (item, searchPasien) {
            final String itemPasien =
                item.child.toString().toLowerCase();
            return itemPasien
                .contains(searchPasien.toLowerCase());
          },
        ),
        //This to clear the search value when you close the menu
        onMenuStateChange: (isOpen) {
          if (!isOpen) {
            searchPasien.clear();
          }
        },
      ),
    ),
  ),
),

it work in release mode but in debug mode run sucessfuly. I hope can run in both. thanks

0

There are 0 answers