build method

  1. @override
InlineSpan build()
override

Implementation

@override
InlineSpan build() {
  final space = config.li.marginLeft;
  final marginBottom = config.li.marginBottom;
  final parentStyleHeight =
      (parentStyle?.fontSize ?? config.p.textStyle.fontSize ?? 16.0) *
          (parentStyle?.height ?? config.p.textStyle.height ?? 1.2);
  Widget marker;
  if (isCheckbox) {
    marker = ProxyRichText(
      children.removeAt(0).build(),
      richTextBuilder: visitor.richTextBuilder,
    );
  } else {
    marker = config.li.marker?.call(isOrdered, depth, index) ??
        getDefaultMarker(isOrdered, depth, parentStyle?.color, index,
            parentStyleHeight / 2, config);
  }
  return WidgetSpan(
    child: Padding(
      padding: EdgeInsets.only(bottom: marginBottom),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          SizedBox(
            width: space,
            child: marker,
          ),
          Flexible(
            child: ProxyRichText(
              TextSpan(
                children: [
                  if (children.isNotEmpty) children.first.build(),
                  for (final child in children.skip(1)) ...[
                    // Introducing a new line before the next list item.
                    // Otherwise, it might be rendered on the same line, disrupting the layout.
                    if (child is UlOrOLNode) const TextSpan(text: '\n'),
                    child.build(),
                  ],
                ],
              ),
              richTextBuilder: visitor.richTextBuilder,
            ),
          ),
        ],
      ),
    ),
  );
}