FlexLine class

A Row or Column that lays its children out the way CSS lays out a flex line (css-flexbox-1 §9), and nothing else: no wrapping, no grid, no layout engine behind it -- a RenderBox over RenderBox children.

Two of the rules it follows have no equivalent in Flutter's own flex:

  • Everyone gives up room, in proportion to how much they asked for (§9.7). When the items do not fit, each gives up shrink × its base size of the overflow, and its base size is what the child measures at -- which nothing outside the child knows before layout, so no Flexible(flex: …) written in the source can say it.
  • An item stops shrinking at its own content (§4.5). Its automatic minimum along the line is its min-content size: its longest word, its widest cell. A Flexible has no floor and crushes the word. An item that wants none says so with min: 0 or FlexCell.clips.

Everything else is the ordinary flex line: flex-grow, a flex basis, an item's own main and cross size, min and max along both axes, margins (auto ones included), a gap, justify-content and align-items -- MainAxisAlignment and CrossAxisAlignment say those two, since they are the same six and five keywords.

The line asks its children what it needs through Flutter's own protocol: a max-content size is RenderBox.getMaxIntrinsicWidth, a min-content size is RenderBox.getMinIntrinsicWidth, the size a child takes in the room there is, or at a length it is held to, is a dry layout.

A child that takes part on CSS's own terms -- it shrinks, it never grows, it starts from its own content -- needs no wrapper at all. A FlexCell says the rest.

Inheritance

Constructors

FlexLine({Key? key, Axis direction = Axis.horizontal, bool reverse = false, double? maxExtent, MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start, CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.stretch, double spacing = 0, double? spacingFraction, bool wrap = false, double runSpacing = 0, double? runSpacingFraction, WrapAlignment? alignContent, bool reverseLines = false, bool balance = false, int lineCount = 1, TextDirection textDirection = TextDirection.ltr, bool safeMainAxis = false, bool safeCrossAxis = false, TextBaseline textBaseline = TextBaseline.alphabetic, List<Widget> children = const <Widget>[]})
const

Properties

alignContent → WrapAlignment?
align-content: where the LINES sit across a box that wraps, and nothing at all where it does not -- a box of one line has no room left between its lines to give away (css-flexbox-1 8.4). null is CSS's normal, which on a flex box is stretch: every line grows by an equal share of the room left over. Anything else packs the lines at the size they came to.
final
balance → bool
flex-wrap: balance (css-flexbox-2 5.2): the lines of a box that wraps come out as alike in length as they can be. The box makes as many lines as plain wrapping would -- lineCount where that is more, and never more than one per item -- and divides its items among them in the order they are written so that the sum of the lines' squared lengths is least, ties going to the most items on the earliest lines. No line of two or more items is longer than the box, and an item of no length stays at the end of the line before it. The box's own max-content length is then its longest line, the items balanced across lineCount lines with no length to stop them, and a column whose height nobody stated is as tall as its tallest line.
final
children → List<Widget>
The widgets below this widget in the tree.
finalinherited
crossAxisAlignment → CrossAxisAlignment
align-items: where the items sit across the line. CrossAxisAlignment.stretch is CSS's default and makes every item as deep as the line.
final
direction → Axis
Which way the line runs. The cross axis is the other one.
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
lineCount → int
flex-line-count (css-flexbox-2 6.1): the fewest lines a balanced box divides its items into, and how many lines share the room ACROSS it. Every item is measured in one line's share: the room less the runSpacing between the lines, divided by the count, so a sentence in a column of two lines wraps at half the column's width. Where the gaps leave no room to share, the room is not divided at all. A length the item states across the line is still the length it is measured at, and a share of the box's depth (FlexCell.crossSizeFraction) is of the whole of it: "Percentages continue to resolve as normal." A box that does not balance takes the count as nothing at all -- it neither adds lines nor shares the room, which is what Chrome draws for a plain wrap (fixtures/flex-line-count-wrap) -- and a box that does not wrap has one line.
final
mainAxisAlignment → MainAxisAlignment
justify-content: what happens to the room left along the line. Where there is none to give -- the items overflow -- CSS still centres or ends them, so the line hangs out of both edges, which is what MainAxisAlignment.center does here and not what a Row does.
final
maxExtent → double?
max-width down a row, max-height down a column: the longest the box may be ALONG the line, whatever room it is offered. It is a ceiling on the box, so it is a ceiling on the room the items are laid out in: they shrink into it as they would into a slot that size, and a wrapping line whose length is left to its content breaks against it. A floor the box is held to still wins over it, as CSS's does (css-sizing-3 5.1).
final
reverse → bool
row-reverse and column-reverse: whether the items run from the far end of direction back to its near one. The first child is then the rightmost of a row, the bottom one of a column, and the main START of the line is the edge they begin at -- so a reversed row under MainAxisAlignment.start packs against its right edge.
final
reverseLines → bool
flex-wrap: wrap-reverse: the lines of a box that wraps stack from the FAR side of the cross axis -- up from the bottom of a row, in from the right of a column -- and what flex-start names across a line turns round with them (css-flexbox-1 5.2). An item aligned to start sits at the bottom of its row, stretch is start wherever it cannot fill, items on one baseline are packed down against the line's bottom edge, and alignContent's start packs the lines at the bottom of the box. The items still break into lines in the order they are written and each line runs the way it did; the box's first baseline comes from the line that is first on the page, the LAST one written (css-flexbox-1 8.5). A line that does not wrap has one line and nothing to stack.
final
runSpacing → double
row-gap where the line is a row, column-gap where it is a column: the room between one line and the next. It is no room at all where there is only one line.
final
runSpacingFraction → double?
spacing and runSpacing as a SHARE of the line's own content box along the same axis: a percentage column-gap is of the box's width, a row-gap of its height (css-align-3 8.3). The box has that length where it was handed it -- a tight constraint on that axis -- and nowhere else: a gap that is a share of a length the box is still working out is cyclic, and resolves against zero. Added to the pixels beside it, so calc(5% + 4px) is a share of 0.05 and 4.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
safeCrossAxis → bool
safe in front of align-items: an item deeper than its line sits at the start of the cross axis -- the top of a row, the left of a column, its right under rtl -- instead of where crossAxisAlignment puts it. An item with an align-self of its own (FlexCell.align) says for itself (FlexCell.safe).
final
safeMainAxis → bool
safe in front of justify-content (css-align-3 4.4): the mainAxisAlignment holds while the items fit the line, and where they overflow it they are packed at the START of the axis instead -- the left of a row, the right of a right-to-left one, the top of a column, reversed or not -- so nothing is pushed out of reach past that edge.
final
spacing → double
gap: the room between one item and the next.
final
spacingFraction → double?
spacing and runSpacing as a SHARE of the line's own content box along the same axis: a percentage column-gap is of the box's width, a row-gap of its height (css-align-3 8.3). The box has that length where it was handed it -- a tight constraint on that axis -- and nowhere else: a gap that is a share of a length the box is still working out is cyclic, and resolves against zero. Added to the pixels beside it, so calc(5% + 4px) is a share of 0.05 and 4.
final
textBaseline → TextBaseline
Which baseline CrossAxisAlignment.baseline lines the items up on.
final
textDirection → TextDirection
direction: which way the INLINE axis runs -- a row's main axis, a column's cross axis (css-flexbox-1 5.1). Right to left, a row runs from its right edge, as reverse makes it, and the two compose: a reversed right-to-left row runs left to right. A column puts what is aligned to start at its right edge, and a column that wraps stacks its lines in from the right. Every margin stays on the side it is written on. Unlike a Row, and like the flex box it stands for, the line does not read the Directionality round it: it runs left to right unless it is told.
final
wrap → bool
flex-wrap: whether the items that do not fit start another line instead of shrinking past their floors (css-flexbox-1 9.3 step 5). Every line then flexes on its own, and the box is as deep as all of them together.
final

Methods

createElement() → MultiChildRenderObjectElement
RenderObjectWidgets always inflate to a RenderObjectElement subclass.
inherited
createRenderObject(BuildContext context) → RenderFlexLine
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
This method is called when a RenderObject that was previously associated with this widget is removed from the render tree. The provided RenderObject will be of the same type as the one created by this widget's createRenderObject method.
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
updateRenderObject(BuildContext context, covariant RenderFlexLine 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