繁体   English   中英

Flutter TextField 禁用边框

[英]Flutter TextField disabled with border

当我使用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))),
            ),
          ),

TextField 小部件的图像

如何使用enabled参数设置为true保持边框的 TextField 小部件?

为了解决这个问题,我从InputDecoration添加了disabledBorder参数并将其设置为OutlineInputBorder(borderSide: BorderSide(color: Color(0xfff7b733)))

做这样的事情:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM