-
-
Notifications
You must be signed in to change notification settings - Fork 882
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
Added support for tables using RichText. #60
Conversation
The RichText renderer now successfully handles the table in the example/main.dart file, and appears to handle that entire html properly. Except there is some extra whitespace at the beginning of block elements. I'm working on removing that. |
lib/html_parser.dart
Outdated
parseContext.parentElement.children.add(span); | ||
} else { | ||
print('doing nothing'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just make this a comment since it doesn't really affect the average user?
print('doing nothing'); | |
//Doing nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
Tables are rendered using Column>Row>Expanded Widgets colspan attributes are honored, but no computation is made over the whole table. That is, if different rows have different numbers of cells, browsers will create an empty dummy cell to keep the columns lined up. This code will simply create a row with a different number of cells and the columns will no longer line up. In the future, the parser should use a scrolling grid layout instead of columns and rows, but that will require significant modifications to the way the parser currently works. I'm still hoping for a native html widget from the Flutter developers! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one more issue I noticed, then I'll merge.
Thanks for being so willing to contribute to the project!
lib/html_parser.dart
Outdated
parseContext.parentElement is LinkTextSpan) { | ||
String lastString = parseContext.parentElement.text ?? ''; | ||
if (!parseContext.parentElement.children.isEmpty) { | ||
lastString = parseContext.parentElement.children.last.text; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had an issue with endsWith(' ')
(below) getting called on a null lastString
.
lastString = parseContext.parentElement.children.last.text; | |
lastString = parseContext.parentElement.children.last.text ?? ''; |
Adding the ?? ''
fixed the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
No description provided.