SliverVisibility class
Whether to show or hide a sliver child.
By default, the visible property controls whether the sliver is included in the subtree or not; when it is not visible, the replacementSliver is included instead.
A variety of flags can be used to tweak exactly how the sliver is hidden. (Changing the flags dynamically is discouraged, as it can cause the sliver subtree to be rebuilt, with any state in the subtree being discarded. Typically, only the visible flag is changed dynamically.)
These widgets provide some of the facets of this one:
- SliverOpacity, which can stop its sliver child from being painted.
- SliverOffstage, which can stop its sliver child from being laid out or painted.
- TickerMode, which can stop its child from being animated.
- ExcludeSemantics, which can hide the child from accessibility tools.
- SliverIgnorePointer, which can disable touch interactions with the sliver child.
Using this widget is not necessary to hide children. The simplest way to hide a child is just to not include it. If a child must be given (e.g. because the parent is a StatelessWidget), then including a childless SliverToBoxAdapter instead of the child that would otherwise be included is typically more efficient than using SliverVisibility.
See also:
- Visibility, the equivalent widget for boxes.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- SliverVisibility
Constructors
- SliverVisibility({Key? key, required Widget sliver, Widget replacementSliver = const SliverToBoxAdapter(), bool visible = true, bool maintainState = false, bool maintainAnimation = false, bool maintainSize = false, bool maintainSemantics = false, bool maintainInteractivity = false})
-
Control whether the given
sliver
isvisible
.const - SliverVisibility.maintain({Key? key, required Widget sliver, Widget replacementSliver = const SliverToBoxAdapter(), bool visible = true})
-
Control whether the given
sliver
isvisible
.const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- maintainAnimation → bool
-
Whether to maintain animations within the sliver subtree when it is
not visible.
final
- maintainInteractivity → bool
-
Whether to allow the sliver to be interactive when hidden.
final
- maintainSemantics → bool
-
Whether to maintain the semantics for the sliver when it is hidden (e.g.
for accessibility).
final
- maintainSize → bool
-
Whether to maintain space for where the sliver would have been.
final
- maintainState → bool
-
Whether to maintain the State objects of the sliver subtree when it is
not visible.
final
- replacementSliver → Widget
-
The widget to use when the sliver child is not visible, assuming that
none of the
maintain
flags (in particular, maintainState) are set.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sliver → Widget
-
The sliver to show or hide, as controlled by visible.
final
- visible → bool
-
Switches between showing the sliver or hiding it.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited