从右到左TextFormField

时间:2018-06-25 09:23:38

标签: dart flutter

在图标和文本位于右侧的情况下如何使用TextFormField小部件?

我当前正在使用以下代码:

new TextFormField(
    obscureText: obscure,
    style: const TextStyle(
        color: Colors.white,
    ),
    decoration: new InputDecoration(
        icon: new Icon(
            icon,
            color: Colors.white,
        ),
        border: InputBorder.none,
        hintText: hint,
        hintStyle: const TextStyle(color: Colors.white, fontSize: 15.0),
        contentPadding: const EdgeInsets.only(
        top: 30.0, right: 30.0, bottom: 30.0, left: 5.0),
    ),
)

1 个答案:

答案 0 :(得分:1)

添加textAligin:TextAlign.end并使用suffixIcon

 new TextFormField(
    textAlign: TextAlign.end,
    obscureText: obscure,
    style: const TextStyle(
        color: Colors.white,
    ),
    decoration: new InputDecoration(
        suffixIcon: new Icon(
            icon,
            color: Colors.white,
        ),
        border: InputBorder.none,
        hintText: hint,
        hintStyle: const TextStyle(color: Colors.white, fontSize: 15.0),
        contentPadding: const EdgeInsets.only(
        top: 30.0, right: 30.0, bottom: 30.0, left: 5.0),
    ),
)