buildWidgetSpanPlaceHolder static method

List<PlaceholderDimensions>? buildWidgetSpanPlaceHolder(
  1. InlineSpan span, {
  2. List<PlaceholderDimensions>? values,
})

查找span中WidgetSpan的数量

Implementation

static List<PlaceholderDimensions>? buildWidgetSpanPlaceHolder(
    InlineSpan span,
    {List<PlaceholderDimensions>? values}) {
  if (values == null) {
    values = [];
  }
  if (span == null) {
    return values;
  }
  if (span is TextSpan) {
    if (span.children != null) {
      for (InlineSpan child in span.children!) {
        values = buildWidgetSpanPlaceHolder(child, values: values);
      }
    }
  } else if (span is SizedWidgetSpan) {
    values.add(PlaceholderDimensions(
        size: Size(span.width ?? 1, span.height ?? 1),
        alignment: ui.PlaceholderAlignment.top));
    return values;
  } else if (span is WidgetSpan) {
    values.add(PlaceholderDimensions(
        size: Size(1, 1), alignment: ui.PlaceholderAlignment.top));
    return values;
  }
  return values;
}