I am a JavaScript developer and I am new to Flutter. I just want to animate a set of images on mouse hover like this using Flutter for Web. It includes Scaling, Opacity and Grayscale transformations. How to accomplish this in Flutter? Thanks in advance.
You just need to install the package running this command flutter pub add hovering or adding hovering: ^1.0. 4 to your dependencies. Then you can use HoverWidget , HoverContainer , HoverAnimatedContainer , and some more. It's not perfect, but it's an easy way to do it, specially for not complicated animations.
The hover effect library gives a 3d hover effect like any box or container etc. we rotate it around the top, bottom, left, right so it is 3d changes its position in style, in this, we can change its shadow color, depthColor etc.
Other than the animation part of your question. The onHover
argument of the InkWell
only works if you specify the onTap
argument first.
InkWell(
child: SomeWidget(),
onTap: () {
//You can leave it empty, like that.
}
onHover: (isHovering) {
if (isHovering) {
//The mouse is hovering.
} else {
//The mouse is no longer hovering.
}
}
)
From the documentation, here's the benefit of the boolean
, which is passed to the onHover
callback:
The value passed to the callback is true if a pointer has entered this part of the material and false if a pointer has exited this part of the material.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With