Flutter无法正确使用文本字段

时间:2019-07-29 11:05:52

标签: flutter dart

我无法正确看到文本字段内写的文本 另外,当我到达TextField的末尾时,我的文本消失了 我通过将TextField封装到直到今天一直有效的Expanded Widget中来解决

https://imgur.com/XjsWqwX

SizedBox(
      height: device.height * 39 / 812,
      width: double.infinity,
      child: Container(
        padding: EdgeInsets.all(7),
        margin: EdgeInsets.only(top: 7),
        decoration: BoxDecoration(
          border: new Border.all(color: Color.fromRGBO(49, 80, 175, 0.36)),
          color: Color.fromRGBO(249, 248, 255, 1),
          borderRadius: new BorderRadius.all(
            Radius.circular(7.0),
          ),
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: <Widget>[
            Container(
              margin: EdgeInsets.only(left: 7, right: 10),
              child: CheckBox(
                null,
                false,
                Colors.white,
              ),
            ),
            Container(
              alignment: Alignment.bottomCenter,
              width: 300,
              // height: 30,
              color: Colors.red,
              child: TextFormField(
                decoration: new InputDecoration(
                  border: InputBorder.none,
                  focusedBorder: InputBorder.none,
                ),
              ),
            ),
          ],
        ),
      ),
    );

1 个答案:

答案 0 :(得分:0)

尝试使用“灵活”小部件包装文本字段,如下所示

灵活(     子代:集装箱(       填充:EdgeInsets.fromLTRB(3.0,3.0,3.0,12.0),       子:TextFormField(                   装饰:新的InputDecoration(                   边框:InputBorder.none,                   focusedBorder:InputBorder.none,      ),     )   )