flutter - 如何定位更改flutter TextFormField前缀图标?

标签 flutter

我尝试更改 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,
  ),
)

enter image description here

最佳答案

我认为您正在尝试将 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/

相关文章:

android - 为什么 ListView 不显示用户输入的文本

flutter - 为什么在 Pubspec.lock flutter sdk 版本为 : "0.0.0"? 如何安全地锁定 flutter 版本?

android - Flutter AppUpdateService 链接到死亡

Firebase 电话验证 : some users don't receive OTP

添加第一方依赖项后 Flutter Xcode 构建失败

flutter - Google表格获取日期值作为数字问题

ios - 如何修复此 Flutter iOS 构建错误?

flutter - Flutter 中 PageController 的提供者状态管理

firebase - 使用 Dart .sort() 函数对 AsyncSnapshot<QuerySnapshot<Object?>> 中的 Firebase 数据进行排序

Flutter:向 Map 添加数据(而不是替换数据)