調(diào)整 TextField
高度进副,使用 SizedBox
包裹自阱,設(shè)置 SizedBox
高度為自定義高度;
調(diào)整 TextField
上下邊距思灌,達(dá)到居中效果,關(guān)鍵代碼:
contentPadding: const EdgeInsets.symmetric(horizontal: 4, vertical: 8),
SizedBox(
height: 40,
child: TextField(
controller: _controller,
style: const TextStyle(color: Colors.white),
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(horizontal: 4, vertical: 8),
labelText: 'xxxx',
labelStyle: const TextStyle(color: Colors.white30,),
filled: true, // 啟用填充背景顏色
fillColor: colorRGB(0x333333),
border: OutlineInputBorder( // 添加邊框
borderRadius: BorderRadius.circular(8.0),
borderSide: BorderSide.none, // 無邊框
),
floatingLabelBehavior: FloatingLabelBehavior.never, // 取消文本上移效果
),
),
),