build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Builds the widget tree for this flex container.

This method creates a LayoutBoxWidget widget configured with the flex layout properties. It resolves the text direction from the ambient Directionality if not explicitly provided, and constructs a FlexLayout object with all the flex-specific configuration.

The build process:

  1. Resolves the text direction for RTL support
  2. Creates a FlexLayout with all flex properties
  3. Wraps everything in a LayoutBoxWidget for rendering

The resulting widget tree handles all the complex flexbox layout calculations and provides scrolling, overflow handling, and visual styling.

Implementation

@override
Widget build(BuildContext context) {
  final resolvedTextDirection =
      textDirection ?? Directionality.maybeOf(context) ?? TextDirection.ltr;
  return LayoutBoxWidget(
    textDirection: resolvedTextDirection,
    reversePaint: reversePaint,
    horizontalController: horizontalController,
    verticalController: verticalController,
    horizontalOverflow: horizontalOverflow,
    verticalOverflow: verticalOverflow,
    diagonalDragBehavior: diagonalDragBehavior,
    reverseHorizontalScroll: horizontalOverflow.reverse,
    reverseVerticalScroll: verticalOverflow.reverse,
    mainScrollDirection: direction.axis == LayoutAxis.horizontal
        ? Axis.vertical
        : Axis.horizontal,
    textBaseline: textBaseline,
    borderRadius: borderRadius,
    clipBehavior: clipBehavior,
    layout: FlexLayout(
      direction: direction,
      wrap: wrap,
      maxItemsPerLine: maxItemsPerLine,
      maxLines: maxLines,
      padding: padding.resolve(
        layoutTextDirectionFromTextDirection(resolvedTextDirection),
      ),
      rowGap: rowGap,
      columnGap: columnGap,
      alignItems: alignItems,
      alignContent: alignContent,
      justifyContent: justifyContent,
    ),
    children: children,
  );
}