Skip to content

Commit 55727dd

Browse files
committed
content [nfc]: Push TextSpan calls down into _buildInlineSpan
This was basically the only appropriate way to use the return value of _buildInlineList, so it might as well get pushed inside the function itself.
1 parent b1fae1b commit 55727dd

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/widgets/content.dart

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Paragraph extends StatelessWidget {
9797
// The paragraph has vertical CSS margins, but those have no effect.
9898
if (node.nodes.isEmpty) return const SizedBox();
9999

100-
final text = Text.rich(TextSpan(children: _buildInlineList(node.nodes)));
100+
final text = Text.rich(_buildInlineSpan(node.nodes, style: null));
101101

102102
// If the paragraph didn't actually have a `p` element in the HTML,
103103
// then apply no margins. (For example, these are seen in list items.)
@@ -122,9 +122,9 @@ class Heading extends StatelessWidget {
122122
assert(node.level == HeadingLevel.h6);
123123
return Padding(
124124
padding: const EdgeInsets.only(top: 15, bottom: 5),
125-
child: Text.rich(TextSpan(
125+
child: Text.rich(_buildInlineSpan(
126126
style: const TextStyle(fontWeight: FontWeight.w600, height: 1.4),
127-
children: _buildInlineList(node.nodes))));
127+
node.nodes)));
128128
}
129129
}
130130

@@ -297,12 +297,15 @@ class _SingleChildScrollViewWithScrollbarState
297297
// Inline layout.
298298
//
299299

300-
List<InlineSpan> _buildInlineList(List<InlineContentNode> nodes) =>
301-
nodes.map(_buildInlineNode).toList(growable: false);
300+
InlineSpan _buildInlineSpan(List<InlineContentNode> nodes, {required TextStyle? style}) {
301+
return TextSpan(
302+
style: style,
303+
children: nodes.map(_buildInlineNode).toList(growable: false));
304+
}
302305

303306
InlineSpan _buildInlineNode(InlineContentNode node) {
304307
InlineSpan styled(List<InlineContentNode> nodes, TextStyle style) =>
305-
TextSpan(children: _buildInlineList(nodes), style: style);
308+
_buildInlineSpan(nodes, style: style);
306309

307310
if (node is TextNode) {
308311
return TextSpan(text: node.text);
@@ -362,8 +365,7 @@ InlineSpan inlineCode(InlineCodeNode node) {
362365
// TODO `code`: find equivalent of web's `unicode-bidi: embed; direction: ltr`
363366

364367
// Use a light gray background, instead of a border.
365-
return TextSpan(style: _kInlineCodeStyle,
366-
children: _buildInlineList(node.nodes));
368+
return _buildInlineSpan(style: _kInlineCodeStyle, node.nodes);
367369

368370
// Another fun solution -- we can in fact have a border! Like so:
369371
// TextStyle(
@@ -428,7 +430,7 @@ class UserMention extends StatelessWidget {
428430
return Container(
429431
decoration: _kDecoration,
430432
padding: const EdgeInsets.symmetric(horizontal: 0.2 * kBaseFontSize),
431-
child: Text.rich(TextSpan(children: _buildInlineList(node.nodes))));
433+
child: Text.rich(_buildInlineSpan(node.nodes, style: null)));
432434
}
433435

434436
static get _kDecoration => BoxDecoration(

0 commit comments

Comments
 (0)