visitElement method
- Element node
override
Implementation
@override
void visitElement(Element node) {
if (isVoidElement(node.localName)) {
return;
}
final bool isTr = node.localName == 'tr';
final bool isTd = node.localName == 'td';
final bool isTh = node.localName == 'th';
if (isTr) {
_currentRow = <SmoothTableCell>[];
}
if (isTd) {
_addTdText = true;
_leftAlign = true;
final String? style = node.attributes['style'];
if (style != null && style.contains('text-align:right')) {
_leftAlign = false;
}
_buffer.clear();
}
if (isTh) {
_addThText = true;
_buffer.clear();
}
visitChildren(node);
if (isTr) {
_cells.add(_currentRow);
}
if (isTd) {
_addTdText = false;
_currentRow.add(
SmoothTableCell(
text: _buffer.toString(),
isHeader: false,
leftAlign: _leftAlign,
),
);
}
if (isTh) {
_addThText = false;
_currentRow.add(
SmoothTableCell(text: _buffer.toString(), isHeader: true),
);
}
}