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
WidgetSpan: exception was thrown when set TextOverflow and MaxLines #35869
Comments
three places i found , need to be changed and it seem that over flow widgets are also calling build method, any performance problems for them? |
you can use blow mentioned lines ConstrainedBox( |
How do you get the crash to happen? I ran the code and scrolled around but didn't get any crash. |
@justinmc sorry, it should make sure text is over flow, i have update the demo codes, please try it |
Thanks, now I can definitely reproduce it! Running the given code immediately logs the error. So the problem has to do with ending an overflowing line with a WidgetSpan. Seems like it's probably a bug in Flutter that should be fixed. |
@justinmc I have another problem about widgetspan I'm working for add widgetspan support for https://github.com/fluttercandies/extended_text and try to do selection with widgetspan, but _textPainter.getOffsetForCaret return Offset.zero when textspan has widgetspans, could you please report to flutter team about it? i'm try to work with workaround to fix it, but i think it's something wrong with flutter engine. thanks. |
@chunhtai Have you run into the above problem with WidgetSpan in your selectable text work? |
The current plan for selectable text is to only allow textspan. I don't think this will affect my work |
Flutter might not support caret position with WidgetSpan right now then. It might be something worth adding, though. |
_textPainter.getBoxesForSelection is right for WidgetSpan, so I do a workaround for get caret position with selection boxs. |
We need to sort out what does it mean to copy/paste a widget span, and it might require a detail discussion |
@chunhtai When it comes a emoticon which user want to insert into |
@zmtzawqlp I agree that should the correct behavior in this use case. The discussion is more about how we expose the api to enable this and what is the default behavior should be like. @AlexVincent525 |
Finished investigation, the crashing is caused by widgetspan being truncated in engine side due to ellipsis. The fix should be ignore the widgetspan if there is no location returns from engine. will put up a pr to fix this |
@chunhtai ok,thanks,we should take care of them |
@chunhtai Is the pull request been included in |
@AlexVincent525 This should be included. Can you share a reproducible example for the issue you are facing? |
@chunhtai The code below was 100% reproduce the issue under my environment.
Error log:
flutter doctor
|
By reviewing the ————————LINE BREAKER————————
hitTestChildren method should add childIndex and be like:while (child != null && childIndex < _textPainter.inlinePlaceholderBoxes.length) {
And
————————LINE BREAKER————————
while (child != null && childIndex < _textPainter.inlinePlaceholderBoxes.length) {
————————LINE BREAKER————————
while (child != null && childIndex < _textPainter.inlinePlaceholderBoxes.length) {
|
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Steps to Reproduce
reproduce with following codes:
Logs
I have done some changes in packages\flutter\lib\src\rendering\paragraph.dart, i think we should take care of over flow widgets .
please take a look attached paragraph.zip.
paragraph.zip
The text was updated successfully, but these errors were encountered: