首页 > 解决方案 > 当使用空格时,flutter-autocomplete-textfield 不提示

问题描述

我正在使用autocomplete_textfield并且它工作得很好,直到我在 2 个单词之间添加一个空格,它停止建议任何东西.. 这是我的代码:

AutoCompleteTextField<String>(
                          decoration: InputDecoration(
                              filled: true,
                              fillColor: Colors.white,
                              hintText: S.of(context).starting_location_hint),
                          itemFilter: (suggestion, input) => suggestion
                              .toLowerCase()
                              .contains(input.toLowerCase()),
                          suggestions: suggestions,
                          itemSorter: (String a, String b) {
                            return a.compareTo(b);
                          },
                          itemSubmitted: (String data) async {
                            cardKey.currentState.toggleCard();
                            fromPicked = true;
                            fromLocationName = data;
                            await movingCameraToLocation(
                                double.parse(
                                    allStations[suggestions.indexOf(data)]
                                        .stationLatitude),
                                double.parse(
                                    allStations[suggestions.indexOf(data)]
                                        .stationLongitude));
                            setState(() {});
                          },
                          itemBuilder:
                              (BuildContext context, String suggestion) {
                            return Padding(
                              padding: const EdgeInsets.all(8.0),
                              child: Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: <Widget>[
                                  Text(
                                    suggestion,
                                    textAlign: TextAlign.right,
                                    style: TextStyle(fontSize: 12),
                                  )
                                ],
                              ),
                            );
                          },
                          key: startKey,
                        )

有什么帮助吗?

标签: androidiosflutterdart

解决方案


推荐阅读