I use the following code:
Widget getSelectSortBy() {
return InkWell(
onHover: (value) {
setState(() {
_isHoveringSortBy = value;
});
},
// onTap needs to be implemented
// otherwise onHover does NOT work! */don't know why/*
onTap: () => {},
child: AnimatedContainer(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(16)),
color: blueSortBy,
border: Border.all(
color: _isHoveringSortBy
? Colors.white
: Colors.transparent,
width: 1.0)),
duration: timeHoveringBottomAnimatedContainer,
padding: EdgeInsets.only(top: 8, bottom: 9, left: 20, right: 28),
child: Row(
// rest of the code of Row
)
);
}
I figured out that I need to implement the onTap() method for the InkWell Widget. Otherwise, the onHover() method won't work.
The question now is, why is this necessary? Or have I implemented something wrong?
Note: I tested this on Chrome with Flutter for the web. (I don't know if there are different circumstances.)