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

已下附上代码:

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: '请输入您的手机号',
              ),
            )),
          )
        ],
      ),
    );
  }

 

已下是效果

19.8.22   自定义了一个输入框

相关文章:

  • 2022-12-23
  • 2021-11-22
  • 2021-08-10
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-07
  • 2022-12-23
  • 2021-06-24
  • 2021-07-04
  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
相关资源
相似解决方案