19.8.22 自定义了一个输入框

系统提供的输入框还是有很多坑的,比如无法改变边框的粗细和颜色等。所以只能自己自定义一个了

已下附上代码:

复制代码
Widget _textFieldWidget() {
    return Container(
      margin: EdgeInsets.only(top: 50),
      height: 50,
      width: ScreenUtil.screenWidthDp - 90,
      decoration: BoxDecoration(
          color: Colors.grey[200],
          borderRadius: BorderRadius.all(Radius.circular(10)),
          border: Border.all(width: 1, color: Colors.grey[300])),
      child: Row(
        children: <Widget>[
          Container(
            margin: EdgeInsets.only(left: 10, right: 10),
            child: Icon(Icons.phone),
          ),
          Container(
            child: Expanded(
                child: TextField(
              onSubmitted: (text) {
                print('提交:' + text);
              },
              onChanged: (String text) {
                print('改变了:' + text);
              },
              decoration: InputDecoration.collapsed(
                hintText: '请输入您的手机号',
              ),
            )),
          )
        ],
      ),
    );
  }
复制代码

 

已下是效果

posted @   走路蹩脚的火星人  阅读(243)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示