ConstraintLayout class
A super powerful Stack, build flexible layouts with constraints. Similar to ConstraintLayout for Android and AutoLayout for iOS. But the code implementation is much more efficient, it has O(n) layout time complexity and no linear equation solving is required.
It is a layout and a more modern general layout framework.
No matter how complex the layout is and how deep the constraints are it has almost the same performance as a single Flex or Stack. When facing complex layouts, it provides better performance, flexibility and a very flat code hierarchy than Flex and Stack. Say no to 'nested hell'.
Flutter ConstraintLayout has extremely high layout performance. It does not require linear equations to solve. At any time, each child element will only be laid out once. When its own width or height is set to wrapContent, some child elements may calculate the offset twice.
ConstraintLayout itself can be arbitrarily nested without performance issues, each child element in the render tree is only laid out once, and the time complexity is O(n) instead of O(2n) or worse.
Warning: For layout performance considerations, constraints are always one-way, and there should be no two child elements directly or indirectly restrain each other(for example, the right side of A is constrained to the left side of B, and the left side of B is in turn constrained to A right). Each constraint should describe exactly where the child elements are located. Although constraints can only be one-way, you can still better handle things that were previously (Android ConstraintLayout) two-way constraints, such as chains(not yet supported, please use with Flex).
author: hackware home page: https:///github.com/hackware1993 email: hackware1993@gmail.com
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- RenderObjectWidget
- MultiChildRenderObjectWidget
- ConstraintLayout
- Available Extensions
Constructors
-
ConstraintLayout({Key? key, List<
ConstraintDefine> ? childConstraints, List<Widget> ? children, bool showLayoutPerformanceOverlay = false, bool showHelperWidgets = false, bool showClickArea = false, bool showZIndex = false, bool showChildDepth = false, bool debugPrintConstraints = false, double width = matchParent, double height = matchParent, double? size, ConstraintLayoutController? controller, bool rtl = false})
Properties
-
childConstraints
→ List<
ConstraintDefine> ? -
Constraints can be separated from widgets
final
-
children
→ List<
Widget> -
The widgets below this widget in the tree.
finalinherited
- controller → ConstraintLayoutController?
-
Every frame, ConstraintLayout compares the parameters and decides the following things:
final
- debugPrintConstraints → bool
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double
-
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- rtl → bool
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showChildDepth → bool
-
Will show the constraint depth (layout priority) of each child element
final
- showClickArea → bool
-
Will show the click area of each child element
final
- showHelperWidgets → bool
-
Guideline and Barrier will be displayed
final
- showLayoutPerformanceOverlay → bool
-
It will display the time-consuming of constraint calculation, layout, and drawing
final
- showZIndex → bool
-
Will show the z-index of each child element
final
- size → double?
-
When size is non-null, both width and height are set to size
final
- width → double
-
final
Methods
-
createElement(
) → MultiChildRenderObjectElement -
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.
override
-
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.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited