CustomBoxy class abstract
A widget that uses a delegate to control the layout of multiple children.
This is essentially a more powerful version of CustomMultiChildLayout, it allows you to inflate, constrain, and lay out each child manually, it also allows the size of the widget to depend on the layout of its children.
In most cases this is overkill, you may want to check if some combination of Stack, LayoutBuilder, CustomMultiChildLayout, and Flow is more suitable.
Boxy supports both sliver and box render protocols for its own RenderObject, and arbitrary children. Which protocols you use is going to affect the constructor and delegate to implement.
- Use the default constructor and BoxyDelegate to create a RenderBox that only has RenderBox children.
- Use the CustomBoxy.box constructor and BoxBoxyDelegate to implement a RenderBox with any child type.
- Use the CustomBoxy.sliver constructor and SliverBoxyDelegate to implement a RenderSliver with any child type.
When implementing a BoxBoxyDelegate or SliverBoxyDelegate, delegates can access BoxyChild and SliverBoxyChild wrappers by passing type arguments to BaseBoxyDelegate.getChild, for example:
final box = getChild<BoxyChild>(#box);
final sliver = getChild<SliverBoxyChild>(#sliver);
Children can be given an id using BoxyId, otherwise they are given an incrementing int id in the provided order, for example:
CustomBoxy(
delegate: MyBoxyDelegate(),
children: [
Container(color: Colors.red)), // Child 0
BoxyId(id: #green, child: Container(color: Colors.green)),
Container(color: Colors.green)), // Child 1
],
);
See also:
- BoxyDelegate, used with the default constructor.
- BoxBoxyDelegate, used with CustomBoxy.box.
- SliverBoxyDelegate, used with CustomBoxy.sliver.
- Inheritance
Constructors
-
CustomBoxy({Key? key, required BoxyDelegate<
Object> delegate, List<Widget> children}) -
Constructs a CustomBoxy with BoxyDelegate that can manage BoxyChild
children.
constfactory
-
CustomBoxy.box({Key? key, required BoxBoxyDelegate<
Object> delegate, List<Widget> children, InflatedChildHandleFactory childFactory}) -
Constructs a CustomBoxy with BoxBoxyDelegate that can manage both
BoxyChild and SliverBoxyChild children.
constfactory
-
CustomBoxy.sliver({Key? key, required SliverBoxyDelegate<
Object> delegate, List<Widget> children, InflatedChildHandleFactory childFactory}) -
Constructs a CustomBoxy with SliverBoxyDelegate that can manage both
BoxyChild and SliverBoxyChild children.
constfactory
Properties
- childFactory → InflatedChildHandleFactory
-
Factory function that constructs an appropriate BaseBoxyChild
based on the the generic type argument.
final
-
children
→ List<
Widget> -
The list of children this boxy is a parent of.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → InflatingElement -
RenderObjectWidgets always inflate to a RenderObjectElement subclass.
inherited
-
createRenderObject(
BuildContext context) → RenderObject -
Creates an instance of the RenderObject class that this
RenderObjectWidget represents, using the configuration described by this
RenderObjectWidget.
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
-
didUnmountRenderObject(
covariant RenderObject renderObject) → void -
A render object previously associated with this widget has been removed
from the tree. The given RenderObject will be of the same type as
returned by this object's createRenderObject.
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}) → 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
-
updateRenderObject(
BuildContext context, covariant RenderObject renderObject) → void -
Copies the configuration described by this RenderObjectWidget to the
given RenderObject, which will be of the same type as returned by this
object's createRenderObject.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
defaultChildFactory<
T extends InflatedChildHandle> ({required Object id, required InflatingRenderObjectMixin< RenderObject, InflatingParentData< parent, RenderObject? render, Element? context, Widget? widget}) → TRenderObject> , InflatedChildHandle> - The default child handle factory for BaseBoxyChild subclasses, constructs an appropriate child based on the the generic type argument.