An InputDecorator, which is typically created by a TextField, cannot have an unbounded width

Flutter运行时报如下错误

An InputDecorator, which is typically created by a TextField, cannot have an unbounded width.
image.png

原因

TextField 没有被限定大小。

解决方法

使用Container包起来,如果时column或者row可以用Expanded包起来。

                          content: Container(
                            width: 200,
                            child: TextField(
                              controller: _textEditingController,
                              decoration: const InputDecoration(hintText: "请输入数据"),
                            ),
                          ),

猜你喜欢

转载自blog.csdn.net/yikezhuixun/article/details/129797691