SliverVisibility constructor Null safety

const SliverVisibility(
  1. {Key? key,
  2. required Widget sliver,
  3. Widget replacementSliver = const SliverToBoxAdapter(),
  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 sliver is visible.

The sliver and replacementSliver arguments must not be null.

The boolean arguments must not be null.

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 SliverVisibility({
  super.key,
  required this.sliver,
  this.replacementSliver = const SliverToBoxAdapter(),
  this.visible = true,
  this.maintainState = false,
  this.maintainAnimation = false,
  this.maintainSize = false,
  this.maintainSemantics = false,
  this.maintainInteractivity = false,
}) : assert(sliver != null),
     assert(replacementSliver != null),
     assert(visible != null),
     assert(maintainState != null),
     assert(maintainAnimation != null),
     assert(maintainSize != null),
     assert(maintainSemantics != null),
     assert(maintainInteractivity != null),
     assert(
       maintainState == true || maintainAnimation == false,
       'Cannot maintain animations if the state is not also maintained.',
     ),
     assert(
       maintainAnimation == true || maintainSize == false,
       'Cannot maintain size if animations are not maintained.',
     ),
     assert(
       maintainSize == true || maintainSemantics == false,
       'Cannot maintain semantics if size is not maintained.',
     ),
     assert(
       maintainSize == true || maintainInteractivity == false,
       'Cannot maintain interactivity if size is not maintained.',
     );