How to add a Password input type in flutter makes the password user input is not visible , just like Android Native EditText 's inputtype:password?

naivor picture naivor · Aug 31, 2018 · Viewed 52.1k times · Source

i meet a problem that Flutter 's TextInputType do not have a password type:

/// All possible enum values.

static const List<TextInputType> values = const <TextInputType>[
  text, multiline, number, phone, datetime, emailAddress, url,
];

how to make the password user input not visible? any one has a good idea ?

Answer

Maurits van Beusekom picture Maurits van Beusekom · Aug 31, 2018

In case you are using the TextField widget (or something that derives from this widget), you can use the obscureText property and set it to true.

More details can be found here: https://docs.flutter.io/flutter/material/TextField/obscureText.html

Additionally, consider adding these properties to prevent input suggestions because they risk revealing at least part of the password input to screen viewers.

enableSuggestions: false,
autocorrect: false,