SpacedRow constructor

SpacedRow({
  1. Key? key,
  2. required List<Widget> children,
  3. double? spacing,
  4. Widget? separator,
  5. MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start,
  6. MainAxisSize mainAxisSize = MainAxisSize.max,
  7. CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center,
  8. TextDirection? textDirection,
  9. VerticalDirection verticalDirection = VerticalDirection.down,
  10. TextBaseline? textBaseline,
})

separatorspacing 둘 중 하나만 사용이 가능하다. mainAxisAlignmentspacingseparator에도 적용되니 유의해야 한다.

Implementation

SpacedRow({
  super.key,
  required List<Widget> children,
  this.spacing,
  this.separator,
  this.mainAxisAlignment = MainAxisAlignment.start,
  this.mainAxisSize = MainAxisSize.max,
  this.crossAxisAlignment = CrossAxisAlignment.center,
  this.textDirection,
  this.verticalDirection = VerticalDirection.down,
  this.textBaseline, // NO DEFAULT: we don't know what the text's baseline should be
})  : assert(
        spacing == null || separator == null,
        '[separator]와 [spacing] 둘 중 하나만 사용이 가능합니다.',
      ),
      assert(
        spacing == null || spacing > 0.0,
        'spacing은 0.0이상의 값이어야 합니다.',
      ) {
  if (children.length < 2 || (spacing == null && separator == null)) {
    _children = children;
  } else if (separator != null) {
    _children = List.generate(
      children.length * 2 - 1,
      (index) => index.isEven ? children[index ~/ 2] : separator!,
    );
  } else {
    _children = List.generate(
      children.length * 2 - 1,
      (index) => index.isEven ? children[index ~/ 2] : Gap(spacing ?? 0),
    );
  }
}