dart – 如何使flofter TextField高度匹配容器的父级?
发布时间:2020-12-14 14:50:05 所属栏目:百科 来源:网络整理
导读:我想让TextField高度与容器高度相同.请检查下面的代码,让我知道如何使我的容器的TextField match_parent.我已经检查了这个问题 The equivalent of wrap_content and match_parent in flutter?,但没有找到任何解决方案.我需要让TextField获取容器的完整高度和
我想让TextField高度与容器高度相同.请检查下面的代码,让我知道如何使我的容器的TextField match_parent.我已经检查了这个问题
The equivalent of wrap_content and match_parent in flutter?,但没有找到任何解决方案.我需要让TextField获取容器的完整高度和宽度.
new Container( height: 200.0,decoration: new BoxDecoration( border: new Border.all(color: Colors.black) ),child: new SizedBox.expand( child: new TextField( maxLines: 2,style: new TextStyle( fontSize: 16.0,// height: 2.0,color: Colors.black ),decoration: const InputDecoration( hintText: "There is no data",contentPadding: const EdgeInsets.symmetric(vertical: 40.0),) ),),) 请检查下面的截图,我需要我的TextField来获取容器的全高度 解决方法
让我们删除代码中的几行,并了解flutter的工作原理.
>为什么我们给容器高度200. Container不能根据子节点调整高度(在本例中为SizedBox.expand) 显示上述图像的最终版本代码 new Container( // height: 200.0,decoration: new BoxDecoration( border: new Border.all(color: Colors.black) ),child: new TextField( maxLines: 2,style: new TextStyle( fontSize: 16.0,color: Colors.black ),decoration: const InputDecoration( hintText: "There is no data",// contentPadding: const EdgeInsets.symmetric(vertical: 40.0),) ),) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读