如果按照Flutter默認(rèn)樣式钾虐,創(chuàng)建的TextField會(huì)出現(xiàn)以下圖片中的這種情況
即使按照網(wǎng)上的更改其中的textalign和contentpadding也無(wú)濟(jì)于事
contentpadding需要一點(diǎn)一點(diǎn)根據(jù)父組件來(lái)微調(diào)位置噪窘,textalign直接無(wú)效了。
(路人:就我一個(gè)人設(shè)置了一下contentpadding就好了嗎)
修復(fù):設(shè)置TextField里面的decoration對(duì)應(yīng)的InputDecoration中的boder參數(shù)
會(huì)自動(dòng)校正文字的位置
代碼:
```??
TextField( InputDecoration( focusedBorder: OutlineInputBorder( borderSide: BorderSide(width:0, color: Colors.transparent)), disabledBorder: OutlineInputBorder( borderSide: BorderSide(width:0, color: Colors.transparent)), enabledBorder: OutlineInputBorder( borderSide: BorderSide(width:0, color: Colors.transparent)), border: OutlineInputBorder( borderSide: BorderSide(width:0, color: Colors.transparent)), contentPadding: EdgeInsets.symmetric(vertical:0), ),//other config ),?
```