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

In 1.0.0, shrinkWrap: true does not provide a size to the layout engine #290

Closed
red42 opened this issue May 13, 2020 · 5 comments · Fixed by #530
Closed

In 1.0.0, shrinkWrap: true does not provide a size to the layout engine #290

red42 opened this issue May 13, 2020 · 5 comments · Fixed by #530

Comments

@red42
Copy link

red42 commented May 13, 2020

This is an issue when using shrinkWrapped Html widgets inside rows. On 1.0.0-pre.1 the element would have the size of its contents and get rendered properly.

For instance, this:

Row(
  children: [
    Html(data: 'Hello', shrinkWrap: true),
    Text(' world'),
  ]
)

Throws The following assertion was thrown during performLayout(): BoxConstraints forces an infinite width.

@red42
Copy link
Author

red42 commented May 13, 2020

Maybe this should not return double.infinity width for shrinkWrapped elements? It does solve the issue in my use cases, but I'm not sure it won't break other use cases.

class StyledText extends StatelessWidget {
  final InlineSpan textSpan;
  final Style style;

  const StyledText({
    this.textSpan,
    this.style,
  });

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width:
          style.display == Display.BLOCK || style.display == Display.LIST_ITEM
              ? double.infinity
              : null,
      child: Text.rich(
        textSpan,
        style: style.generateTextStyle(),
        textAlign: style.textAlign,
        textDirection: style.direction,
      ),
    );
  }
}

Relevant code

@fatherOfLegends
Copy link

This has completely broken shrinkWrap. Any chance we can get this fixed?

@mit-73
Copy link

mit-73 commented Sep 21, 2020

@red42 it helped me:

style: {
        "html": Style(
          display: Display.INLINE,
        ),
        "body": Style(
          display: Display.INLINE,
        ),
       "...": Style(
          display: Display.INLINE,
        ),
}

@akshaybhange
Copy link

@red42 it helped me:

style: {
        "html": Style(
          display: Display.INLINE,
        ),
        "body": Style(
          display: Display.INLINE,
        ),
       "...": Style(
          display: Display.INLINE,
        ),
}

This worked for me .. but the issue should be solved ASAP

@philos3
Copy link

philos3 commented May 24, 2022

@red42 it helped me:

style: {
        "html": Style(
          display: Display.INLINE,
        ),
        "body": Style(
          display: Display.INLINE,
        ),
       "...": Style(
          display: Display.INLINE,
        ),
}

This worked for me .. but the issue should be solved ASAP

still has the problem with below html code:

<p style="text-align: center;"><img src="https://img.lightsnail.com/def/90416202205160036053532.jpg" width="858" height="471" style="width: 858px; height: 471px;"/></p>

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.

5 participants