首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >颤振searchable_dropdown隐藏键盘

颤振searchable_dropdown隐藏键盘
EN

Stack Overflow用户
提问于 2020-04-25 13:01:12
回答 2查看 767关注 0票数 0

我使用searchable_dropdown https://pub.dev/packages/searchable_dropdown

当用户触摸输入文本字段时,如何只显示键盘?

所有示例都显示,只要用户单击下拉按钮,键盘就会显示出来。

如果您检查属于该包的searchable_dropdown.dart,则键盘焦点将设置为真

代码语言:javascript
复制
  Widget searchBar() {
    return new Container(
      child: new Stack(
        children: <Widget>[
          new TextField(
            controller: txtSearch,
            decoration: InputDecoration(
                contentPadding:
                    EdgeInsets.symmetric(horizontal: 32, vertical: 12)),
            autofocus: true,

当用户触摸输入文本字段时,如何只显示键盘?

EN

回答 2

Stack Overflow用户

发布于 2021-01-25 20:22:16

searceable_dropdown.dart中查找searchBar小部件并将自动焦点更改为false不要忘记运行pub get

代码语言:javascript
复制
 Widget searchBar() {
    return new Container(
      child: new Stack(
        children: <Widget>[
          new TextField(
            controller: txtSearch,
            decoration: InputDecoration(
                contentPadding:
                    EdgeInsets.symmetric(horizontal: 32, vertical: 12)),
            autofocus: false,//Here change from true to false
            onChanged: (value) {
              _updateShownIndexes(value);
              setState(() {});
            },
            keyboardType: widget.keyboardType,
          ),
          new Positioned(
            left: 0,
            top: 0,
            bottom: 0,
            child: new Center(
              child: new Icon(
                Icons.search,
                size: 24,
              ),
            ),
          ),
          txtSearch.text.isNotEmpty
              ? new Positioned(
                  right: 0,
                  top: 0,
                  bottom: 0,
                  child: new Center(
                    child: new InkWell(
                      onTap: () {
                        _updateShownIndexes('');
                        setState(() {
                          txtSearch.text = '';
                        });
                      },
                      borderRadius: BorderRadius.all(Radius.circular(32)),
                      child: new Container(
                        width: 32,
                        height: 32,
                        child: new Center(
                          child: new Icon(
                            Icons.close,
                            size: 24,
                          ),
                        ),
                      ),
                    ),
                  ),
                )
              : new Container(),
        ],
      ),
    );
  }
票数 0
EN

Stack Overflow用户

发布于 2021-08-10 11:16:27

我找到了解决办法。去上searchable_dropdown.dart课。在第871或877行,将出现自动对焦: true。只是转换真正的=>筋膜。关闭项目并重新启动。这会管用的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61426045

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档