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

天蓝Sea

关注

阅读 100

2023-03-27

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: "请输入数据"),
                            ),
                          ),

精彩评论(0)

0 0 举报