initialize method

void initialize()

Implementation

void initialize() {
  if (widget.focusNode != null) {
    _focus = widget.focusNode;
  } else {
    _focus = FocusNode();
  }
  _focus!.addListener(() {
    if (mounted) {
      setState(() {
        isSuggestionExpanded = _focus!.hasFocus;
      });
    }
    if (widget.hasOverlay) {
      if (isSuggestionExpanded) {
        if (widget.initialValue == null) {
          if (widget.suggestionState == Suggestion.expand) {
            Future.delayed(const Duration(milliseconds: 100), () {
              suggestionStream.sink.add(widget.suggestions);
            });
          }
        }
        Overlay.of(context).insert(_overlayEntry);
      } else {
        _overlayEntry.remove();
      }
    } else {
      if (isSuggestionExpanded) {
        if (widget.initialValue == null) {
          if (widget.suggestionState == Suggestion.expand) {
            Future.delayed(const Duration(milliseconds: 100), () {
              suggestionStream.sink.add(widget.suggestions);
            });
          } else {
            Future.delayed(const Duration(milliseconds: 100), () {
              suggestionStream.sink.add(null);
            });
          }
        }
      } else {
        Future.delayed(const Duration(milliseconds: 100), () {
          suggestionStream.sink.add(null);
        });
      }
    }
  });
}