In Android, every single View
subclass has a setVisibility()
method that allows you modify the visibility of a View
object
The
Update
Flutter now has a Visibility widget. To implement your own solution start with the below code.
Make a widget yourself.
show/hide
class ShowWhen extends StatelessWidget {
final Widget child;
final bool condition;
ShowWhen({this.child, this.condition});
@override
Widget build(BuildContext context) {
return Opacity(opacity: this.condition ? 1.0 : 0.0, child: this.child);
}
}
show/remove
class RenderWhen extends StatelessWidget {
final Widget child;
final bool condition;
RenderWhen({this.child, this.show});
@override
Widget build(BuildContext context) {
return this.condition ? this.child : Container();
}
}
By the way, does any one have a better name for the widgets above?
More Reads