flutter Row嵌套TextField出错

发布时间 2024-01-05 16:28:15作者: hczhhm

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

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

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

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

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