withDivider method

IntrinsicHeight withDivider({
  1. double width = 1,
  2. Color? color,
  3. double thickness = 1,
  4. double indent = 0,
  5. double endIndent = 0,
})

Add a divider between each child. width is the width of the divider. color is the color of the divider. thickness is the thickness of the divider. indent is the indent of the divider. endIndent is the endIndent of the divider. Example:

Row(
children: [
 Text("Hello"),
 Text("World"),
]).withDivider(),

Implementation

IntrinsicHeight withDivider(
    {double width = 1,
    Color? color,
    double thickness = 1,
    double indent = 0,
    double endIndent = 0}) {
  List<Widget> newChildren = [];
  for (int i = 0; i < children.length; i++) {
    newChildren.add(children[i]);
    if (i < children.length - 1) {
      newChildren.add(VerticalDivider(
        width: width,
        color: color ?? Colors.grey.shade300,
        thickness: thickness,
        indent: indent,
        endIndent: endIndent,
      ));
    }
  }

  return IntrinsicHeight(
    child: Row(
      key: this.key,
      mainAxisAlignment: this.mainAxisAlignment,
      mainAxisSize: this.mainAxisSize,
      crossAxisAlignment: this.crossAxisAlignment,
      textDirection: this.textDirection,
      verticalDirection: this.verticalDirection,
      textBaseline: this.textBaseline,
      children: newChildren,
    ),
  );
}