Skip to content

Commit 91e202a

Browse files
committed
content [nfc]: Add _BlockInlineContainer widget, as a stub
This doesn't yet do much, but will.
1 parent 8f3f0d6 commit 91e202a

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

lib/widgets/content.dart

Lines changed: 33 additions & 3 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 = InlineContent(nodes: node.nodes, style: null);
100+
final text = _buildBlockInlineContainer(node: node, 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: InlineContent(
125+
child: _buildBlockInlineContainer(
126126
style: const TextStyle(fontWeight: FontWeight.w600, height: 1.4),
127-
nodes: node.nodes));
127+
node: node));
128128
}
129129
}
130130

@@ -297,6 +297,36 @@ class _SingleChildScrollViewWithScrollbarState
297297
// Inline layout.
298298
//
299299

300+
Widget _buildBlockInlineContainer({
301+
required TextStyle? style,
302+
required BlockInlineContainerNode node,
303+
}) {
304+
if (node.links == null) {
305+
return InlineContent(style: style, nodes: node.nodes);
306+
}
307+
return _BlockInlineContainer(
308+
links: node.links!, style: style, nodes: node.nodes);
309+
}
310+
311+
class _BlockInlineContainer extends StatefulWidget {
312+
const _BlockInlineContainer(
313+
{required this.links, required this.style, required this.nodes});
314+
315+
final List<LinkNode> links;
316+
final TextStyle? style;
317+
final List<InlineContentNode> nodes;
318+
319+
@override
320+
State<_BlockInlineContainer> createState() => _BlockInlineContainerState();
321+
}
322+
323+
class _BlockInlineContainerState extends State<_BlockInlineContainer> {
324+
@override
325+
Widget build(BuildContext context) {
326+
return InlineContent(style: widget.style, nodes: widget.nodes);
327+
}
328+
}
329+
300330
class InlineContent extends StatelessWidget {
301331
InlineContent({
302332
super.key,

0 commit comments

Comments
 (0)