How can I make the code below that works in onPressed state work in onHover state?
class _MyState extends State<MyPage> {
bool _flag = true;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () => setState(() => _flag = !_flag), //
child: Text(_flag ? 'Red' : 'Green'),
style: ElevatedButton.styleFrom(
primary: _flag ? Colors.red : Colors.teal,
),
),
),
);
}
}
Note : it didn't work onHover: (isHovering) {setState(() { _flag = !_flag ;});},