Flutter TextField autocomplete overlay

前端 未结 4 1012
梦谈多话
梦谈多话 2021-02-07 15:14

I am struggling to create TextField with autocomplete overlay. I have form with TextFields and I want to display suggestions based on what is typed in TextField.

Someth

4条回答
  •  一个人的身影
    2021-02-07 15:32

    You can make use of autocomplete_textfield library to achieve that.

    Basic Usage

      ...
    
                    SimpleAutoCompleteTextField(
                      key: key,
                      suggestions: [
                        "Apple",
                        "Armidillo",
                        "Actual",
                        "Actuary",
                        "America",
                        "Argentina",
                        "Australia",
                        "Antarctica",
                    "Blueberry",],
                      decoration: InputDecoration(
                        filled: true,
                        fillColor: Colors.black12,
                        hintText: 'Dictionary'
                      ),
                    ),
    
                    ...  
    

    You can get more examples here.

    Another Option

    You can also make use of flutter_typeahead

    This worked better for me when working with StreamBuilderfor BLoC pattern.

提交回复
热议问题