Open tomk9 opened 2 years ago
Thank you. I'm able to reproduce the issue. Looking into it now
I've identified the issue as related to https://github.com/flutter/flutter/issues/65895. The assertion can safely be ignored in this case. I'll do some additional testing to ensure this is handled correctly in future versions, but a temporary workaround is to add RenderObject.debugCheckingIntrinsics = true;
to the beginning of your build method.
@Sub6Resources just make it possible to change WidgetSpan.alignment
outside the widget. It's hardcoded in your code now:
return WidgetSpan(
alignment: PlaceholderAlignment.baseline,
baseline: TextBaseline.alphabetic,
child: CssBoxWidget.withInlineSpanChildren(
key: context.key,
...
Another easy way is to expose the property selectable
outside the HtmlParser
. It's hardcoded now, just make it customizable in the Html
widget. So, making the widget selectable can help me workaround the issue with alphabetic alignment.
However, the most flexible and successful solution is to make both of this properties (selectable
in Html
and placeholderAlignment
in Style
) customizable.
I respectfully vote against making it an option. This should work out of the box and if that means not using baseline alignment than that's probably fine.
I respectfully vote against making it an option. This should work out of the box and if that means not using baseline alignment than that's probably fine.
Why? Optionality is always useful and can't be a problem anyway.
Also it's impossible to use baseline alignment in the IntrinsicHeight
due to the issue in the FlutterSDK which @Sub6Resources mentioned. Thus, you just have no choice. The only way is to help Flutter developers to fix the issue in the FlutterSDK. Can you? No? So, vote for optionality ;)
If there is no any IntrinsicHeight widgets in a widget tree, why not to use baseline alignment? Somebody could need it.
And finally, Flutter developers afford themselves to have such optionality in the out-of-box widgets (Text
, IntrinsicHeight
are still exist in this world), so why not to have this optionality in other widgets? But I absolutely agree to have some notice about this issue in the documentation to this widget.
Optionally means more maintenance work and more support. Why not make sure IntrinsicHeight is supported out of the box so anyone can use it without having to raad documentation (best case scenario) on how to set up the right parameters?
It worked before we had CssBox so I'm sure we can work something out. Like using bottom alignment by default.
The work is already done. Your suggestion is to do additional work to remove already written code or replace it with another hardcoded values.
I suggest just exposing a couple of properties for client code. Moreover, if there were optional properties, the widget would be ready to use when the Flutter issue is solved. If you're afraid of documentation, it's very easy to write assert in the Style
constructor for the new placeholderAlignment
property and make it bottom
by default. What can be easier?
Anyway, here is my PR if you'd like the solution https://github.com/Sub6Resources/flutter_html/pull/1191
I was experiencing a similar issue, so I hadn't updated from 3.0.0-alpha.5
until now. Using the provided workaround didn't work for me
a temporary workaround is to add
RenderObject.debugCheckingIntrinsics = true;
to the beginning of your build method.
I had a Row
wrapped in an IntrinsicHeight
with two Columns
, one of which contains an Html
widget. If the height of the Html
widget exceeded that of the other column, using this workaround would just make the Html
widget overflow its contents outside of the Row
instead of expanding the whole Row
vertically until it fit. Without this workaround, it would not render at all.
Using the branch from the provided PR #1306, my issue has been resolved, and I can once again properly render my Widgets.
Is there any expectation for the timeline of this to be merged in a new beta version, or even a full release?
@frankvollebregt can you show me how to use the branch from provided PR. I am using flutter_html: ^3.0.0-beta.2
and facing the similar issue
@ThanhQuang1410 in your pubspec.yaml
, you can add a dependency override, so it looks like this:
dependencies:
...
# This version is currently in your pubspec already
flutter_html: 3.0.0-beta.2
dependency_overrides:
# This is the version that is used for now (until, hopefully, this version gets released at some point)
flutter_html:
git:
url: https://github.com/sub6resources/flutter_html.git
ref: fix/intrinsics-and-table
Thank you @frankvollebregt . Now my app is rendering everything correctly
@frankvollebregt thanks a lot, spent hours on this until i got to your reply.
Describe the bug:
I use
Html
widget nested inIntrinsicHeight
andSingleChildScrollView
as follows:It works well with
flutter_html: 3.0.0-alpha.5
but doesn't work withflutter_html: 3.0.0-alpha.6
. Exception message isExpected behavior:
Should render as on the screenshot from version
3.0.0-alpha.5
.Screenshots:
Device details and Flutter/Dart/
flutter_html
versions:Stacktrace/Logcat
``` _AssertionError._doThrowNew (errors_patch.dart:51) _AssertionError._throwNew (errors_patch.dart:40) RenderParagraph._canComputeIntrinsics (paragraph.dart:502) RenderParagraph._computeIntrinsicHeight (paragraph.dart:459) RenderParagraph.computeMaxIntrinsicHeight (paragraph.dart:474) RenderBox._computeIntrinsicDimension.