'Icon Button relesae tab event in Flutter
Am doing a TextForm Button with Suffex icoon button , I inteneded to show password only while am pressing the button and when I release it it should go back to password format. I could do it only with onyl press.
this is the code
TextFormField(
obscuringCharacter: '#',
obscureText: passwordVisible,
controller: password,
decoration: InputDecoration(
suffixIcon: IconButton(
icon: const Icon(Icons.remove_red_eye),
onPressed: () {
setState(() {
passwordVisible = !passwordVisible;
});
},
),
Solution 1:[1]
I just solved it by adding longpress event
TextFormField(
obscuringCharacter: '#',
obscureText: passwordVisible,
controller: password,
decoration: InputDecoration(
suffixIcon: GestureDetector(
child: IconButton(
icon: const Icon(Icons.remove_red_eye),
onPressed: () {
},
),
onLongPressEnd: (LongPressEndDetails Details){
setState(() {
passwordVisible = true;
});
},
onLongPress: () {
setState(() {
passwordVisible = false;
});
},
),
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 | Bareq Raad |
