我尝试更改 TextFormField 前缀图标位置,但我不明白该怎么做,任何人都知道我使用了如下代码
child: TextFormField(
autocorrect: false,
maxLines: 4,
decoration: InputDecoration(
border: new OutlineInputBorder(
borderSide: new BorderSide(
style: BorderStyle.solid)),
hintStyle: TextStyle(
color: Color.fromRGBO(0, 0, 0, 0.1)),
prefixIcon: Icon(Icons.edit),
hintText: "Onion 1kg",
labelText: 'Item Description (Optional)',
),
style: TextStyle(
color: Color.fromRGBO(25, 25, 35, 1),
fontSize:18,
),
)
最佳答案
我认为您正在尝试将 TextFormField
中的图标位置更改为正确位置,因此只需使用 suffixIcon: Icon(Icons.edit),
而不是 >prefixIcon: Icon(Icons.edit),
所以你的代码将如下所示:
child: TextFormField(
autocorrect: false,
maxLines: 4,
decoration: InputDecoration(
border: new OutlineInputBorder(
borderSide: new BorderSide(
style: BorderStyle.solid)),
hintStyle: TextStyle(
color: Color.fromRGBO(0, 0, 0, 0.1)),
//prefixIcon: Icon(Icons.edit), // this is left side
suffixIcon: Icon(Icons.edit), // this is right side.
hintText: "Onion 1kg",
labelText: 'Item Description (Optional)',
),
style: TextStyle(
color: Color.fromRGBO(25, 25, 35, 1),
fontSize:18,
),
)
关于flutter - 如何定位更改flutter TextFormField前缀图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61031090/