Unwrapper class

A widget that unwraps (skips) a specific parent widget and renders its inner child instead.

This widget attempts to access and render the inner child widget of the provided child, based on certain heuristics:

  • If a resolver callback is provided, it tries to get a custom unwrap result.
  • Otherwise, if the child has a child property, it returns that.
  • Otherwise, if the child has a children property, it returns the child at childrenIndex.
  • If none of the above work, it returns the fallback widget.

If unwrap is false, the widget simply renders the child as is. If wrapperBuilder is provided, it wraps the unwrapped widget with the result of the builder function.

Inheritance

Constructors

Unwrapper.new({Key? key, required Widget child, bool unwrap = true, int childrenIndex = 0, Widget wrapperBuilder(Widget unwrapped)?, Widget? resolver(Widget wrapper)?, Widget fallback = const SizedBox.shrink()})
Creates an Unwrapper.
const

Properties

child Widget
The widget to unwrap.
final
childrenIndex int
The index of the child to select when unwrapping from a widget that has multiple children (e.g., Column).
final
fallback Widget
The widget to render if unwrapping fails.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
resolver Widget? Function(Widget wrapper)?
Optional resolver callback to provide custom unwrapping logic.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
unwrap bool
Whether to perform unwrapping.
final
wrapperBuilder Widget Function(Widget unwrapped)?
Optional builder to wrap the unwrapped widget before rendering.
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.
inherited
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