build method

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

Implementation

@override
Widget build(Context context) {
  final _children = <Widget>[];

  if (reverse) {
    for (var index = itemCount - 1; index >= 0; index--) {
      _children.add(_getItem(context, index));
      if (spacing != 0 && index > 0) {
        _children.add(_getSeparator(context, index));
      }
    }
  } else {
    for (var index = 0; index < itemCount; index++) {
      _children.add(_getItem(context, index));
      if (spacing != 0 && index < itemCount - 1) {
        _children.add(_getSeparator(context, index));
      }
    }
  }

  final Widget widget = Flex(
    direction: direction,
    mainAxisAlignment: MainAxisAlignment.start,
    mainAxisSize: MainAxisSize.max,
    crossAxisAlignment: CrossAxisAlignment.center,
    verticalDirection: VerticalDirection.down,
    children: _children,
  );

  if (padding != null) {
    return Padding(
      padding: padding!,
      child: widget,
    );
  }

  return widget;
}