Jagaa
Jagaa

Reputation: 679

How to change obscure character of text field in flutter?

I want to use '*' instead of '•' in text field.

TextField(
  focusNode: _passwordFocusNode,
  controller: _passwordController,
  obscureText: true,
);

Upvotes: 8

Views: 9128

Answers (3)

Confiance
Confiance

Reputation: 926

TextField(
    obscureText: true,
    obscuringCharacter:'*',
);

Upvotes: 3

Mahesh Jamdade
Mahesh Jamdade

Reputation: 20241

Now flutter does support this feature for a textfield by setting the obscuringCharacter property, it takes a string strict to 1 character and the obscureText property should be true in order to take this effect

TextField(
  obscuringCharacter: '&', // defaults to *
  obscureText: true,
)

Upvotes: 7

Mohamad Assem Nasser
Mohamad Assem Nasser

Reputation: 1109

Flutter currently does not support this feature. Obscuring text is controlled by the property obscureText which takes a boolean expression. As you can see in the docs

When this is set to true, all the characters in the text field are replaced by U+2022 BULLET characters (•).

This issue on GitHub may be of help: https://github.com/flutter/flutter/issues/36377

Upvotes: 3

Related Questions