build method
Builds the FabGroup widget by creating a Fab that, when pressed, displays a Popover containing the buttons returned by children, arranged horizontally or vertically based on horizontal.
Uses a _PopRef
instance wrapped in a Pylon to track the OverlayCompleter
for the popover, enabling programmatic dismissal via dismissFabGroup
. The
popover is positioned with an offset (70 pixels right for vertical, 70 pixels
down for horizontal) and consumes outside taps for automatic closure. Upon
closure, calls dismissFabGroup
to clean up any remaining pylons. Integrates
with showPopover for overlay management and Row/Column for button layout.
Implementation
@override
Widget build(BuildContext context) {
return Fab(
leading: leading,
onPressed: () {
_PopRef ref = _PopRef();
OverlayCompleter o = showPopover(
consumeOutsideTaps: true,
context: context,
offset: horizontal ? const Offset(0, 70) : const Offset(70, 0),
barrierDismissable: true,
builder: (context) => Pylon<_PopRef>(
value: ref,
builder: (context) => horizontal
? Row(
mainAxisSize: MainAxisSize.min,
children: children(context),
)
: Column(
mainAxisSize: MainAxisSize.min,
children: children(context),
),
),
alignment: Alignment.bottomRight);
ref.completer = o;
o.future.then((value) {
context.dismissFabGroup();
});
},
child: child,
);
}