Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to hide password entry in flutter?

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading