OnHover constructor

const OnHover({
  1. Key? key,
  2. required void action(
    1. bool hovering
    ),
  3. required Widget child,
})

Creates an OnHover widget.

The action parameter is called with true when hover begins and false when it ends. The child parameter is the widget that will detect hover events.

Example:

OnHover(
  action: (hovering) {
    setState(() => _isHovered = hovering);
  },
  child: Container(
    color: _isHovered ? Colors.blue : Colors.grey,
    child: Text("Hover to change color"),
  ),
)

Implementation

const OnHover({super.key, required this.action, required this.child});