如何在flutter中更改文本字段的模糊字符?

Jag*_*gaa 7 flutter

我想在文本字段中使用 '*' 而不是 '•'。

TextField(
  focusNode: _passwordFocusNode,
  controller: _passwordController,
  obscureText: true,
);
Run Code Online (Sandbox Code Playgroud)

mah*_*mnj 7

现在,flutter 通过设置obscuringCharacter属性来支持文本字段的此功能,它需要严格限制为 1 个字符的字符串,并且 obliqueText 属性应该为 true 才能实现此效果

TextField(
  obscuringCharacter: '&', // defaults to *
  obscureText: true,
)
Run Code Online (Sandbox Code Playgroud)


Moh*_*ser 4

Flutter 目前不支持此功能。模糊文本由采用布尔表达式的属性obscurText控制。正如您在文档中看到的

\n\n
\n

当此项设置为 true 时,文本字段中的所有字符都将替换为 U+2022 BULLET 字符 (\xe2\x80\xa2)。

\n
\n\n

GitHub 上的这个问题可能会有所帮助:https://github.com/flutter/flutter/issues/36377

\n