Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageSpan not update on Hot reload #19

Open
2dxgujun opened this issue Jun 14, 2019 · 0 comments · May be fixed by #20
Open

ImageSpan not update on Hot reload #19

2dxgujun opened this issue Jun 14, 2019 · 0 comments · May be fixed by #20

Comments

@2dxgujun
Copy link

2dxgujun commented Jun 14, 2019

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;
}
@2dxgujun 2dxgujun linked a pull request Jun 14, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant