BuildOp.inline constructor
BuildOp.inline({
- PlaceholderAlignment alignment = PlaceholderAlignment.baseline,
- TextBaseline baseline = TextBaseline.alphabetic,
- String? debugLabel,
- required OnRenderInlineBlock onRenderInlineBlock,
- int priority = kPriorityInlineBlockDefault,
Creates an inline build op.
Implementation
factory BuildOp.inline({
PlaceholderAlignment alignment = PlaceholderAlignment.baseline,
TextBaseline baseline = TextBaseline.alphabetic,
String? debugLabel,
required OnRenderInlineBlock onRenderInlineBlock,
int priority = kPriorityInlineBlockDefault,
}) =>
BuildOp.v2(
debugLabel: debugLabel,
onParsed: (tree) {
final bits = [...tree.bits];
if (bits.length == 1) {
final bit = bits.first;
if (bit is WidgetBit &&
bit.isInline == true &&
bit.alignment == alignment &&
bit.baseline == baseline) {
// tree has exactly 1 inline bit & all configurations match
// let's reuse the existing placeholder
bit.child.wrapWith((_, w) => onRenderInlineBlock(tree, w));
return tree;
}
}
final parent = tree.parent;
return parent.sub()
..append(
WidgetBit.inline(
parent,
WidgetPlaceholder(
debugLabel: debugLabel,
child: onRenderInlineBlock(tree, tree.build() ?? widget0),
),
alignment: alignment,
baseline: baseline,
),
);
},
priority: priority,
);