buildPopover function
Implementation
Widget buildPopover(BuildContext context, OpenUiNode node) {
final trigger = node.props['trigger'];
final content = node.props['content'];
final parts = trigger is List
? trigger.expand((p) => p is List ? p : [p]).toList()
: [trigger];
final row = Row(
mainAxisSize: MainAxisSize.min,
spacing: 4,
children: [
for (final part in parts)
for (final widget in node.render(
part,
slot: 'trigger${parts.indexOf(part)}',
))
_keepsWidth(part) ? widget : Flexible(child: widget),
],
);
return _Popover(
trigger: switch (trigger) {
String() || num() => _inlineText(context, trigger),
// `.iui-row > * { min-width: 0 }` can squeeze the trigger below its
// `flex: none` parts; they overflow it, as in CSS.
// ponytail: a squeezed trigger with text parts still reports overflow.
_ when parts.every(_keepsWidth) => OverflowBox(
maxWidth: double.infinity,
alignment: AlignmentDirectional.centerStart,
fit: OverflowBoxFit.deferToChild,
child: row,
),
_ => row,
},
content: switch (content) {
String() || num() => _inlineText(context, content),
_ => Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 8,
children: node.render(content, slot: 'content'),
),
},
);
}