Opacity — A Flutter Widget — WalkingTree Technologies

Removing a widget in Flutter is really simple and easy. You just have to rebuild the tree without it. But what if you want the widget to disappear but still take up space on the screen so that it doesn’t disrupt the rest of the layout? Well to solve this, you can try the Opacity widget.

How does it work?

In the code above, the blue widget has been wrapped inside the Opacity widget, with its opacity set to 0.0. This will make the widget completely transparent, i.e. the widget will exist at its place, but you won’t be able to see it. Anything between 0.0 and 1.0 makes the widget partially transparent.

Not just this, you can animate the opacity of the widget also by simply wrapping it inside the AnimatedOpacity widget and setting its opacity and duration.

For more information on the Opacity widget and to see the Flutter’s Widget of the Week video.

Originally published at https://walkingtree.tech on May 5, 2020.