Fade Widgets in Flutter
May 14, 2022
Give your widgets a Faded Effect.
Let’s say we want to fade a widget called WidgetToBeFaded().
We need to wrap it inside ShaderMask() widget. Return LinearGradient().createShader(bounds) inside shaderCallback function;
In Linear Gradient use Black and a Transparent color. Set the blend mode of shader mask to BlendMode.dstIn.
We’re done!! Now the transparency of widget is determined by the Linear Gradient’s transparent color.
I hope this helps. Thanks for reading.