Visibility constructor

const Visibility(
  1. {Key? key,
  2. required Widget child,
  3. Widget replacement = const SizedBox.shrink(),
  4. bool visible = true,
  5. bool maintainState = false,
  6. bool maintainAnimation = false,
  7. bool maintainSize = false,
  8. bool maintainSemantics = false,
  9. bool maintainInteractivity = false}
)

Control whether the given child is visible.

The maintainSemantics and maintainInteractivity arguments can only be set if maintainSize is set.

The maintainSize argument can only be set if maintainAnimation is set.

The maintainAnimation argument can only be set if maintainState is set.

Implementation

const Visibility({
  super.key,
  required this.child,
  this.replacement = const SizedBox.shrink(),
  this.visible = true,
  this.maintainState = false,
  this.maintainAnimation = false,
  this.maintainSize = false,
  this.maintainSemantics = false,
  this.maintainInteractivity = false,
}) : assert(
       maintainState || !maintainAnimation,
       'Cannot maintain animations if the state is not also maintained.',
     ),
     assert(
       maintainAnimation || !maintainSize,
       'Cannot maintain size if animations are not maintained.',
     ),
     assert(
       maintainSize || !maintainSemantics,
       'Cannot maintain semantics if size is not maintained.',
     ),
     assert(
       maintainSize || !maintainInteractivity,
       'Cannot maintain interactivity if size is not maintained.',
     );