美文网首页
flutter Row嵌套TextField出错

flutter Row嵌套TextField出错

作者: hczhhm | 来源:发表于2024-01-08 11:08 被阅读0次

flutter开发中遇到需求需要Row嵌套TextField,运行后发现代码报错:

child: Row(
   children: [
       TextField(
          decoration: InputDecoration(
              hintText: "名称"
          ),
       )
    ],
),

错误码太多了,这里就不贴出来了。

 child: Row(
          children: [
            Expanded(
              child:TextField(
                  decoration: InputDecoration(
                     hintText: "名称"
                  ),
               )
            )
             
          ],
   ),

使用Expanded嵌套一层后就不报错了,为了可以对TextField进行位置设置,我又在Expanded外套了一层Container。

相关文章

网友评论

      本文标题:flutter Row嵌套TextField出错

      本文链接:https://www.haomeiwen.com/subject/vginndtx.html