[英]Flutter TextField disabled with border
When I use the TextField Widget with enabled
parameter set to false
, the border disappears.当我使用enabled
参数设置为false
的 TextField 小部件时,边框消失。
Flexible(
child:
TextField(
onTap: () {
Future<DateTime> dateTime = _buildDataHoraInicial(context);
dateTime.then((date){
_dataHoraInicial = date;
_dataTempoInicialController.text = date.toIso8601String();
print(_dataHoraInicial);
});
},
controller: _dataTempoInicialController,
style: TextStyle(color: Colors.white),
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(vertical: 15.0),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xfff7b733))),
prefixIcon: Icon(
Icons.calendar_today,
color: Color(0xfff7b733),
size: 16.0,
),
suffixIcon: Icon(Icons.access_time,
color: Color(0xfff7b733), size: 16.0),
border: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xfff7b733))),
labelText: 'Data e Hora de Início',
fillColor: Colors.white,
hintStyle: TextStyle(color: Colors.white),
labelStyle: TextStyle(
fontSize: 16.0, color: const Color(0xfff7b733))),
),
),
image of the TextField Widget TextField 小部件的图像
How can I use TextField Widget with enabled
parameter set to true
keeping the border?如何使用enabled
参数设置为true
保持边框的 TextField 小部件?
为了解决这个问题,我从InputDecoration
添加了disabledBorder
参数并将其设置为OutlineInputBorder(borderSide: BorderSide(color: Color(0xfff7b733)))
do sumething like this:做这样的事情:
TextField(
decoration: InputDecoration(
hintText: "Write your address",
border: OutlineInputBorder(borderSide: BorderSide(width: 1, color: Colors.transparent)),
disabledBorder: OutlineInputBorder(borderSide: BorderSide(width: 1, color: Colors.transparent)),
enabledBorder: OutlineInputBorder(borderSide: BorderSide(width: 1, color: Colors.transparent)),
errorBorder: OutlineInputBorder(borderSide: BorderSide(width: 1, color: Colors.transparent)),
focusedBorder: OutlineInputBorder(borderSide: BorderSide(width: 1, color: Colors.transparent)),
focusedErrorBorder: OutlineInputBorder(borderSide: BorderSide(width: 1, color: Colors.transparent)),
),
),
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.