'How to Hide /Show Password Herein listTile in Flutter

child: ListTile(
                leading: Text(
                  surveyorList![index]["mobile_no"],
                  style: TextStyle(
                      fontSize: 22,
                      color: Colors.yellow,
                      fontWeight: FontWeight.bold),
                ),
                title: Center(
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Text('Name'),
                      Text(surveyorList![index]["name"],
                          style:
                              TextStyle(fontSize: 26, color: Colors.redAccent)),
                      **Text('Password'),
                      Text(surveyorList![index]["password"],**
                          style: TextStyle(
                            fontSize: 26,
                            color: Colors.redAccent,
                          )),
                    ],
                  ),
                ),
                trailing: Container(
                  height: 30.0,
                  width: 30.0,
                  decoration: BoxDecoration(
                    image: DecorationImage(
                      image: AssetImage('img/survey.png'),
                      fit: BoxFit.fill,
                    ),
                    shape: BoxShape.circle,
                  ),
                ),
              ),

here is an image showing the password which I want to Hide Unhide



Solution 1:[1]

Use like this:

String a="fsjwn2682o2";
a.replaceAll(new RegExp(r'[a-zA-Z0-9]'),'*');

Solution 2:[2]

If I am understanding correctly by your comment, you can do something like this -

bool hidePassword=true;

Row(
  children: [
     InkWell(
        onTap: () {
           setState(() {
               hidePassword=!hidePassword; 
           });
        }
        //Insert your Icon here. 
        child: Image.asset("assets/images/icon.png"),
     ),
     TextField(
       controller: _passwordController,
       textAlign: TextAlign.center,
       obscureText: hidePassword,
       obscuringCharacter: '?',
     ),
  ]
),

You can try it and tell me if it is working?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lakshydeep Vikram Sah
Solution 2 Shreyansh Sharma