Skip to content
This repository was archived by the owner on Dec 26, 2024. It is now read-only.
This repository was archived by the owner on Dec 26, 2024. It is now read-only.

ImageSpan not update on Hot reload #19

@2dxgujun

Description

@2dxgujun

I figure out that when you trigger a Hot reload, _RichTextWrapper will invoke updateRenderObject and it will call RenderParagraph's text setter to set a new TextSpan which call TextSpan.compareTo to determine whether to accept the new TextSpan or drop it.

Since our ImageSpan is inherited from TextSpan, and we should override the compareTo method to aware the changes of these properties in ImageSpan class.

Here is my patch code, and it works.

@override
RenderComparison compareTo(covariant ImageSpan other) {
  RenderComparison comparison = super.compareTo(other);
  if (other.imageProvider != imageProvider ||
      other.imageWidth != imageWidth ||
      other.imageHeight != imageHeight ||
      other.margin != margin) {
    comparison = RenderComparison.layout;
  }
  return comparison;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions