Home > database >  How to hide password entry in flutter?
How to hide password entry in flutter?

Time:01-12

I am making a Flutter application. I set the login and registration processes. But since I get the password as a string when I enter the password, what can I do to make the password appear as a star on the screen? I used firebase authentication for login and registration.


 Widget _entryField(
      String title,
      TextEditingController controller,
      ) {
    return TextField(
      controller: controller,
      decoration: InputDecoration(
        labelText: title,
      ),
    );



@override
  Widget build(BuildContext context) {
    SizeConfig().init(context);
    return Scaffold(
      appBar: AppBar(
        title: _title(),
      ),body: Container(
      height: double.infinity,
      width: double.infinity,
      padding: const EdgeInsets.all(10),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          _entryField('email', _controllerEmail),
          Padding(padding: EdgeInsets.only(bottom: 10)),
          _entryField('password', _controllerPassword),
          Padding(padding: EdgeInsets.only(bottom: 10)),
          _submitButton(),
          _loginOrRegisterButton(),
        ],
      ),
    ),
    );
  }
}

Issues

CodePudding user response:

You can use obscureText: true

 Widget _entryField(
      String title,
      TextEditingController controller,
      bool isObscureText,
      ) {
    return TextField(
      controller: controller,
      obscureText: isObscureText,//this
      decoration: InputDecoration(

And use

  _entryField('email', _controllerEmail,false),
   Padding(padding: EdgeInsets.only(bottom: 10)),
  _entryField('password', _controllerPassword,true),

I will prefer creating named argument on this case.

Find more about dart language

  • Related