malkasun

Password SHOW/HIDE

Apr 29th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.79 KB | None | 0 0
  1. //  ========SHOW / HIDE PASSWORD METHOD ========
  2.   bool _showPassword = false;
  3.  
  4.   void _togglevisibility() {
  5.     setState(() {
  6.       _showPassword = !_showPassword;
  7.     });
  8.   }
  9.  
  10. // ==========PASSWORD BUTTON CODE =========
  11.  Padding(
  12.                           padding:
  13.                           const EdgeInsets.fromLTRB(12.0, 8.0, 12.0, 8.0),
  14.                           child: Material(
  15.                             color: Colors.white.withOpacity(0.5),
  16.                             borderRadius: BorderRadius.circular(20.0),
  17.                             child: Padding(
  18.                               padding: const EdgeInsets.symmetric(
  19.                                   vertical: 0.0, horizontal: 10.0),
  20.                               child: TextFormField(
  21.                                 controller: _passwordController,
  22.                                 obscureText: !_showPassword,
  23.                                 cursorColor: Colors.red,
  24.                                 style: TextStyle(color: Colors.white),
  25.                                 decoration: InputDecoration(
  26.                                   hintText: "Password",
  27.                                   border: InputBorder.none,
  28.                                   suffixIcon: GestureDetector(
  29.                                     onTap: () {
  30.                                       _togglevisibility();
  31.                                     },
  32.                                     child: Icon(
  33.                                       _showPassword ? Icons.visibility : Icons
  34.                                           .visibility_off, color: Colors.red,),
  35.                                   ),
  36.                                 ),
  37.                               ),
  38.                             ),
  39.                           ),
  40.                         ),
Add Comment
Please, Sign In to add comment