Flutter中Row中不能直接使用textfield控件

解决方案

class LogingUi extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    var size = MediaQuery.of(context).size;
    // TODO: implement build
    return new Stack(
      fit: StackFit.loose,
      children: <Widget>[
        new Container(
          color: Colors.white,
          width: size.width,
          height: size.height,
        ),
        new Column(
          mainAxisSize: MainAxisSize.max,
          children: <Widget>[
            new Container(
              padding: EdgeInsets.all(30),
            ),
            new Row(
              mainAxisAlignment: MainAxisAlignment.center, //对其方式
              children: <Widget>[
                new Image.asset(
                  "images/login_logo.png",
                  width: 119,
                  height: 151,
                  fit: BoxFit.fill,
                ),
              ],
            ),
            new Row(
              children: <Widget>[
                new Expanded(
                    child: new TextField(

                        //相当于Android属性hint
                        decoration: new InputDecoration(
                  hintText: "用户名",
                )))
              ],
            )
          ],
        ),
      ],
    );
  }
}

猜你喜欢

转载自blog.csdn.net/fl2502923/article/details/89285071