Skip to content

Commit

Permalink
perf(pkgs): More flatten html munching
Browse files Browse the repository at this point in the history
More flatten html munching:
* Munching into a `TextSpan` is OK as result.
  • Loading branch information
realth000 committed Nov 29, 2023
1 parent 017f85f commit a5a025f
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions lib/packages/html_muncher/lib/src/html_muncher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,15 @@ class Muncher {
spanList.add(span);
}
}
if (spanList.isNotEmpty) {
// Do not wrap in another layout when there is only one span.
if (spanList.length == 1) {
return spanList.first;
}
widgetList.add(RichText(
text: TextSpan(children: spanList),
textAlign: state.textAlign ?? TextAlign.justify,
));
}
if (widgetList.isEmpty) {
if (spanList.isEmpty) {
// Not intend to happen.
return const TextSpan();
}
// widgetList.add(widgetList.first);
return WidgetSpan(
child: Column(
mainAxisSize: MainAxisSize.min,
children: widgetList,
),
);
// Do not wrap in another layout when there is only one span.
if (spanList.length == 1) {
return spanList.first;
}
return TextSpan(children: spanList);
}

InlineSpan? munchNode(uh.Node? node) {
Expand Down

0 comments on commit a5a025f

Please sign in to comment.