Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change obscure character of text field in flutter?

Tags:

flutter

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

TextField(
  focusNode: _passwordFocusNode,
  controller: _passwordController,
  obscureText: true,
);
like image 311
Jagaa Avatar asked Nov 01 '19 00:11

Jagaa


People also ask

How do you obscure text in Flutter?

To hide an entered password in a TextField/TextFormField, just set its obscureText property to true. To show the entered password for the user to read it, set obscureText to false. to show/hide password in TextFormField in flutter Here we will use Use TextField/TextFormField.

How do you make a TextField Uneditable in Flutter?

Use the enabled: property of the TextField widget by setting it to false : TextField( enabled: false, ... ) This field won't respond to onTap events - it is similar to a disabled field in HTML.

What is obscure text?

obscureText property Null safety bool obscureText. Whether to hide the text being edited (e.g., for passwords). When this is set to true, all the characters in the text field are replaced by obscuringCharacter, and the text in the field cannot be copied with copy or cut.


2 Answers

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,
)
like image 193
Mahesh Jamdade Avatar answered Oct 18 '22 23:10

Mahesh Jamdade


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

like image 3
Mohamad Assem Nasser Avatar answered Oct 19 '22 00:10

Mohamad Assem Nasser