daohoangson / flutter_widget_from_html

Flutter package to render html as widgets that supports hyperlink, image, audio, video, iframe and many other tags.
https://pub.dev/packages/flutter_widget_from_html
MIT License
645 stars 242 forks source link

BoxConstraints has a NaN value in maxWidth. #1329

Open shashankmathur8 opened 2 months ago

shashankmathur8 commented 2 months ago

Steps to Reproduce

`HtmlWidget` configuration SizedBox( width: 1500, height: 1000, child: HtmlWidget(enableCaching: true, onLoadingBuilder: (context, element, loadingProgress) { return CircularProgressIndicator(); }, widget.mainController.currentMail.body.toString())), ```dart ```
Tesing environment ✓ Built build/web shashank@Shashanks-MacBook-Air CRM % flutter doctor -v [✓] Flutter (Channel stable, 3.22.2, on macOS 13.6 22G120 darwin-arm64, locale en-IN) • Flutter version 3.22.2 on channel stable at /Users/shashank/Documents/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 761747bfc5 (3 months ago), 2024-06-05 22:15:13 +0200 • Engine revision edd8546116 • Dart version 3.4.3 • DevTools version 2.34.3 ``` ```

Expected results

No Error

Actual results

======== Exception caught by rendering library ===================================================== The following assertion was thrown during performLayout(): BoxConstraints has a NaN value in maxWidth.

The offending constraints were: BoxConstraints(0.0<=w<=NaN, 0.0<=h<=Infinity; NOT NORMALIZED) The relevant error-causing widget was: HtmlWidget HtmlWidget:file:///Users/shashank/StudioProjects/CRM/lib/common/emailbody.dart:159:36 When the exception was thrown, this was the stack: dart-sdk/lib/_internal/js_dev_runtime/private/ddcruntime/errors.dart 296:3 throw packages/flutter/src/rendering/box.dart 526:9 throwError packages/flutter/src/rendering/box.dart 551:9 packages/flutter/src/rendering/box.dart 583:14 debugAssertIsValid packages/flutter/src/rendering/object.dart 2470:23 layout packages/flutter/src/widgets/widget_span.dart 398:10 performLayout packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/proxy_box.dart 105:21 packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/layout_helper.dart 52:10 layoutChild packages/flutter/src/rendering/paragraph.dart 127:28 _layoutChild packages/flutter/src/rendering/paragraph.dart 158:9 packages/flutter/src/rendering/paragraph.dart 158:50 layoutInlineChildren packages/flutter/src/rendering/paragraph.dart 824:30 performLayout packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/proxy_box.dart 105:21 packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter_widget_from_html_core/src/widgets/css_sizing.dart 236:16 performLayout packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/shifted_box.dart 456:7 performLayout packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/shifted_box.dart 239:5 performLayout packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/layout_helper.dart 52:10 layoutChild packages/flutter_widget_from_html_core/src/widgets/html_table.dart 537:33 step4ChildSizesAndRowHeights packages/flutter_widget_from_html_core/src/widgets/html_table.dart 328:19 compute packages/flutter_widget_from_html_core/src/widgets/html_table.dart 883:23 performLayout packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/proxy_box.dart 105:21 packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/widgets/single_child_scroll_view.dart 476:7 performLayout packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/proxy_box.dart 105:21 packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/proxy_box.dart 105:21 packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/proxy_box.dart 105:21 packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/proxy_box.dart 105:21 packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/proxy_box.dart 105:21 packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/proxy_box.dart 105:21 packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/widgets/layout_builder.dart 333:7 performLayout packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/shifted_box.dart 239:5 performLayout packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/proxy_box.dart 105:21 packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/shifted_box.dart 856:12 performLayout packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/layout_helper.dart 52:10 layoutChild packages/flutter/src/rendering/flex.dart 815:43 [_computeSizes] packages/flutter/src/rendering/flex.dart 885:32 performLayout packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/shifted_box.dart 456:7 performLayout packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/layout_helper.dart 52:10 layoutChild packages/flutter_widget_from_html_core/src/widgets/html_table.dart 537:33 step4ChildSizesAndRowHeights packages/flutter_widget_from_html_core/src/widgets/html_table.dart 328:19 compute packages/flutter_widget_from_html_core/src/widgets/html_table.dart 883:23 performLayout packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/proxy_box.dart 105:21 packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/widgets/single_child_scroll_view.dart 476:7 performLayout packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/proxy_box.dart 105:21 packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/proxy_box.dart 105:21 packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/proxy_box.dart 105:21 packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/proxy_box.dart 105:21 packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/proxy_box.dart 105:21 packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/proxy_box.dart 105:21 packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/widgets/layout_builder.dart 333:7 performLayout packages/flutter/src/rendering/object.dart 2577:7 layout packages/flutter/src/rendering/layout_helper.dart 52:10 layoutChild packages/flutter/src/rendering/flex.dart 815:43 [_computeSizes] packages/flutter/src/rendering/flex.dart 885:32 performLayout packages/flutter/src/rendering/object.dart 2416:7 [_layoutWithoutResize] packages/flutter/src/rendering/object.dart 1051:17 flushLayout packages/flutter/src/rendering/object.dart 1064:14 flushLayout packages/flutter/src/rendering/binding.dart 577:5 drawFrame packages/flutter/src/widgets/binding.dart 1138:13 drawFrame packages/flutter/src/rendering/binding.dart 443:5 [_handlePersistentFrameCallback] packages/flutter/src/scheduler/binding.dart 1392:7 [_invokeFrameCallback] packages/flutter/src/scheduler/binding.dart 1313:9 handleDrawFrame packages/flutter/src/scheduler/binding.dart 1171:5 [_handleDrawFrame] lib/_engine/engine/platform_dispatcher.dart 1404:5 invoke lib/_engine/engine/platform_dispatcher.dart 307:5 invokeOnDrawFrame lib/_engine/engine/initialization.dart 187:36 dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 426:37 _checkAndCall dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 431:39 dcall The following RenderObject was being processed when the exception was fired: _RenderScaledInlineWidget#f0429 relayoutBoundary=up32 NEEDS-PAINT ... needs compositing ... parentData: (can use size) ... constraints: BoxConstraints(w=0.0, 0.0<=h<=Infinity) ... layer: TransformLayer#378a7 ... engine layer: TransformEngineLayer#e3abb ... handles: 2 ... offset: Offset(0.0, 0.0) ... transform: [0] 0.0,0.0,0.0,50.0 [1] 0.0,0.0,0.0,39.7 [2] 0.0,0.0,1.0,0.0 [3] 0.0,0.0,0.0,1.0 ... size: Size(0.0, 0.0) RenderObject: _RenderScaledInlineWidget#f0429 relayoutBoundary=up32 NEEDS-PAINT needs compositing parentData: (can use size) constraints: BoxConstraints(w=0.0, 0.0<=h<=Infinity) layer: TransformLayer#378a7 engine layer: TransformEngineLayer#e3abb handles: 2 offset: Offset(0.0, 0.0) transform: [0] 0.0,0.0,0.0,50.0 [1] 0.0,0.0,0.0,39.7 [2] 0.0,0.0,1.0,0.0 [3] 0.0,0.0,0.0,1.0 size: Size(0.0, 0.0) ... child: RenderConstraintsTransformBox#ba9b5 relayoutBoundary=up33 NEEDS-PAINT ... needs compositing ... parentData: offset=Offset(0.0, 0.0) (can use size) ... constraints: BoxConstraints(unconstrained) ... size: Size(250.0, 160.0) ... alignment: Alignment.topLeft ... textDirection: ltr ... child: _RenderCssSizing#77635 relayoutBoundary=up34 NEEDS-PAINT ... needs compositing ... parentData: offset=Offset(0.0, 0.0) (can use size) ... constraints: BoxConstraints(unconstrained) ... size: Size(250.0, 160.0) ... child: RenderConstraintsTransformBox#1bded relayoutBoundary=up35 NEEDS-PAINT ... needs compositing ... parentData: (can use size) ... constraints: BoxConstraints(250.0<=w<=Infinity, 0.0<=h<=Infinity) ... size: Size(250.0, 160.0) ... alignment: Alignment.topLeft ... textDirection: ltr ... child: _RenderLayoutBuilder#a2fb5 relayoutBoundary=up36 NEEDS-PAINT ... needs compositing ... parentData: offset=Offset(0.0, 0.0) (can use size) ... constraints: BoxConstraints(unconstrained) ... size: Size(158.0, 160.0)

shayebuhuiya commented 2 months ago

I have this problem too when I tried to construct a column widget with width of infinity. I'm doing this because I want put an image widget on center of a new line. "align" attribute seems like invalid for image.

daohoangson commented 2 months ago

What is your HTML?