Sub6Resources / flutter_html

A Flutter widget for rendering static html as Flutter widgets (Will render over 80 different html tags!)
https://pub.dev/packages/flutter_html
MIT License
1.75k stars 805 forks source link

[BUG] Nested tables do not work #1377

Closed emaborsa closed 7 months ago

emaborsa commented 7 months ago

Flutter doctor:

Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.7.10, on Microsoft Windows [Version 10.0.19044.3448], locale de-DE) [X] Windows Version (Unable to confirm if installed Windows version is 10 or greater) Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1) [√] Chrome - develop for the web [√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.7.4) [√] Android Studio (version 2022.1) [√] VS Code, 64-bit edition (version 1.82.2) [√] Connected device (5 available) [√] HTTP Host Availability

! Doctor found issues in 1 category.

Problem:

If I try to render nested tables I got the following error:

=═══════ Exception caught by rendering library ═════════════════════════════════
The following assertion was thrown during performLayout():
LayoutBuilder does not support returning intrinsic dimensions.

Calculating the intrinsic dimensions would require running the layout callback speculatively, which might mutate the live render object tree.
The relevant error-causing widget was
Html
newsletter.dart:65
When the exception was thrown, this was the stack
...
The following RenderObject was being processed when the exception was fired: RenderLayoutGrid#bcdc6 relayoutBoundary=up19 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
RenderObject: RenderLayoutGrid#bcdc6 relayoutBoundary=up19 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
    parentData: offset=Offset(0.0, 0.0) (can use size)
    constraints: BoxConstraints(0.0<=w<=344.0, 0.0<=h<=Infinity)
    size: MISSING
    child 1: RenderConstrainedBox#7f31b NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
        parentData: columnStart=0; columnSpan=1; rowStart=0; rowSpan=1; offset=Offset(0.0, 0.0)
        constraints: MISSING
        size: MISSING
        additionalConstraints: BoxConstraints(w=Infinity, 0.0<=h<=Infinity)
        child: RenderDecoratedBox#4a57c NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
            parentData: <none>
            constraints: MISSING
            size: MISSING
            decoration: BoxDecoration
                color: Color(0x00000000)
            configuration: ImageConfiguration(bundle: PlatformAssetBundle#230c6(), devicePixelRatio: 3.0, locale: de, textDirection: TextDirection.ltr, platform: android)
            child: RenderConstrainedBox#f5105 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
                parentData: <none>
                constraints: MISSING
                size: MISSING
                additionalConstraints: BoxConstraints(biggest)
                child: RenderPositionedBox#372e6 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
                    parentData: <none>
                    constraints: MISSING
                    size: MISSING
                    alignment: Alignment.centerLeft
                    textDirection: ltr
                    widthFactor: expand
                    heightFactor: expand

My code:

import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';

class NewsletterWebViewWidget extends StatelessWidget {
  const NewsletterWebViewWidget({super.key});

  @override
  Widget build(BuildContext context) => Material(
        child: Scaffold(
          extendBodyBehindAppBar: true,
          body: Html(
            data: """
<table>
<tr><td>

<table>
<tr><td></td></tr>
</table>

</td></tr>
</table>
""",
          ),
        ),
      );
}
emaborsa commented 7 months ago

I've just seen this: https://github.com/Sub6Resources/flutter_html/issues/992