I try to do show and hide password but it says Invalid constant value on the _togglePasswordView, And _isHidden I wonder what I did wrong If someone know plz help
bool _isHidden = true;
void _togglePasswordView() {
setState(() {
_isHidden = !_isHidden;
});
}
TextFormField(
obscureText: _isHidden,
decoration: const InputDecoration(
hintText: 'Password',
suffix: InkWell(
onTap: _togglePasswordView,
child: Icon(
_isHidden ? Icons.visibility : Icons.visibility_off,
),
),
),
),
You're using something dynamic (here onTap function), inside a
constconstructor callJUST REMOVE
constKEYWORD and you'll be fine