maheshj01 / searchfield

A highly customizable simple and easy to use flutter Widget to add a searchfield to your Flutter Application.This Widget allows you to search and select from list of suggestions.
MIT License
84 stars 63 forks source link

"The specified entry is already present in the target Overlay." Error #143

Closed tkddbf7348 closed 5 months ago

tkddbf7348 commented 5 months ago

I'm using the searchfield: ^1.0.3 version.

"The specified entry is ready present in the target Overlay." error occurs when tap the field again after tapping the supplement.

In debug mode, only errors occur and move on, but in release mode, the entire screen stops and does not work.

How can I fix it?

SearchField(
      controller: _searchController,
      focusNode: _searchFocusNode,
      itemHeight: MediaQuery.of(context).size.height * .06,
      suggestionState: Suggestion.expand,
      suggestionAction: SuggestionAction.unfocus,
      suggestions: ModeType.values
          .map(
            (e) => SearchFieldListItem<ModeType>(
              e.name,
              item: e,
              child: Obx(
                () {
                  bool selected = (MusicController.inst.modeType.value.level == e.level) &&
                      (MusicController.inst.modeType.value.subLevel == e.subLevel);

                  return Material(
                    color: Colors.transparent,
                    child: Padding(
                      padding:
                          EdgeInsets.only(left: e.subLevel > 0 ? 30.r : 10.r, right: 10.r, top: 10.r, bottom: 10.r),
                      child: Row(
                        children: [
                          Expanded(
                              child: CustomText(
                            e.name,
                            style: TextStyle(
                              fontFamily: pretendardFont,
                              color: selected ? Colors.white : const Color(0xFF9D9D9D),
                              fontWeight: selected
                                  ? FontWeight.bold
                                  : e.subLevel == 0
                                      ? FontWeight.w500
                                      : FontWeight.w400,
                              fontSize: e.subLevel == 0 ? 15 : 14,
                            ),
                          )),
                        ],
                      ),
                    ),
                  );
                },
              ),
            ),
          )
          .toList(),
      searchStyle: const TextStyle(
        color: Colors.white,
        fontFamily: pretendardFont,
        fontSize: 13,
      ),
      suggestionsDecoration: SuggestionDecoration(
        borderRadius: const BorderRadius.only(
          bottomLeft: Radius.circular(13),
          bottomRight: Radius.circular(13),
        ),
        color: const Color(0xFF222222),
      ),
      searchInputDecoration: InputDecoration(
        filled: true,
        contentPadding: EdgeInsets.symmetric(horizontal: 20.r, vertical: 15.r),
        fillColor: const Color(0xFF222222),
        focusedBorder: inputDecoration,
        border: inputDecoration,
        disabledBorder: inputDecoration,
        enabledBorder: inputDecoration,
        errorBorder: inputDecoration,
        focusedErrorBorder: inputDecoration,
        hintText: 'What is your current condition?',
        hintStyle: const TextStyle(
          color: Color(0xFF555555),
          fontFamily: pretendardFont,
        ),
        prefixIcon: IgnorePointer(
          child: IconButton(
            onPressed: () {},
            icon: SvgPicture.asset(
              'assets/svgs/search.svg',
              colorFilter: getColorFilter(const Color(0xFF656565)),
            ),
          ),
        ),
      ),
      onSuggestionTap: (SearchFieldListItem<ModeType> suggestion) async {
          ~
      },
      onSubmit: (text) {},

Fix)

on onSuggestionTapped()

modified this code

      suggestionStream.sink.add(null);
      if (widget.onSuggestionTap != null) {
        widget.onSuggestionTap!(item);
      }

To

      suggestionStream.sink.add(null);
      removeOverlay();
      if (widget.onSuggestionTap != null) {
        widget.onSuggestionTap!(item);
      }

It works well without any problems.

maheshj01 commented 5 months ago

@tkddbf7348 I have submittted a temporary fix, it still resurfaces but I am not able to catch it 100% of the time. The cause its unknown at this time Unfortunately :(

I will leave this issue open until we fix it completely, meanwhile please try this fix by adding the following to pubspec.yaml and let me know.

  searchfield:
    git:
      url: https://github.com/maheshmnj/searchfield.git
      ref: fix-143
tkddbf7348 commented 5 months ago

thank you so much! :)

tkddbf7348 commented 5 months ago

@maheshmnj The branch you fixed works fine on my app! 😊

maheshj01 commented 5 months ago

Thanks for the confirmation @tkddbf7348, I will go ahead and publish this version. Feel free to write back on this issue incase you encounter the error again.

maheshj01 commented 5 months ago

@tkddbf7348 published v1.0.4