compareTo method

  1. @override
RenderComparison compareTo(
  1. InlineSpan other
)
override

Describe the difference between this span and another, in terms of how much damage it will make to the rendering. The comparison is deep.

Comparing InlineSpan objects of different types, for example, comparing a TextSpan to a WidgetSpan, always results in RenderComparison.layout.

See also:

Implementation

@override
RenderComparison compareTo(InlineSpan other) {
  if (identical(this, other)) {
    return RenderComparison.identical;
  }
  if (other.runtimeType != runtimeType) {
    return RenderComparison.layout;
  }
  if ((style == null) != (other.style == null)) {
    return RenderComparison.layout;
  }
  final WidgetSpan typedOther = other as WidgetSpan;
  if (child != typedOther.child || alignment != typedOther.alignment) {
    return RenderComparison.layout;
  }
  RenderComparison result = RenderComparison.identical;
  if (style != null) {
    final RenderComparison candidate = style!.compareTo(other.style!);
    if (candidate.index > result.index) {
      result = candidate;
    }
    if (result == RenderComparison.layout) {
      return result;
    }
  }
  return result;
}