可以看到使用prefixIcon圖標就出現間距問題。網上看了很多文章,好像是沒有什么好的解決辦法,也有可能是太簡單了,別人懶的發(哭笑)。
我把我知道的方法寫出來吧
decoration: InputDecoration( // isCollapsed: true, prefixIcon: Icon(Iconfont.sousuoicon,size: 20,),//添加內部左邊圖標 prefixIconConstraints: BoxConstraints( //添加內部圖標之后,圖標和文字會有間距,實現這個方法,不用寫任何參數即可解決 ), fillColor: ColorKit.hexToColor('#F6F6F6'), filled: true, hintText: '請輸入搜索內容', hintStyle: TextStyle(fontSize: 13), border: OutlineInputBorder( borderRadius: BorderRadius.circular(20), borderSide: BorderSide.none, ), ),
沒錯,就這么簡單
添加這個就行,里面什么都不用寫
prefixIconConstraints: BoxConstraints( //添加內部圖標之后,圖標和文字會有間距,實現這個方法,不用寫任何參數即可解決 ),