系统提供的输入框还是有很多坑的,比如无法改变边框的粗细和颜色等。所以只能自己自定义一个了
已下附上代码:
Widget _textFieldWidget() { return Container( margin: EdgeInsets.only(top: 50), height: 50, ScreenUtil.screenWidthDp - 90, decoration: BoxDecoration( color: Colors.grey[200], borderRadius: BorderRadius.all(Radius.circular(10)), border: Border.all( 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: '请输入您的手机号', ), )), ) ], ), ); }
已下是效果