build method
Describes the part of the UI represented by this widget.
Implementation
@override
Widget build(BuildContext context) {
if (!open) return child;
// Dim the background content so the dialog stands out.
// In a terminal we cannot do true alpha blending, so Opacity applies
// Style().dim() to the child content, letting it remain visible but
// visually receded behind the dialog.
final dimmedChild = backdropOpacity < 1.0 && backdropOpacity > 0.0
? Opacity(opacity: backdropOpacity, child: child)
: child;
// Prevent pointer/scroll events from leaking to background content while
// a modal is open. The dismiss layer and dialog remain interactive.
final blockedBackground = _ModalInputBlocker(
child: IgnorePointer(ignoring: true, child: dimmedChild),
);
// Transparent dismiss layer — sized to fill the stack but paints nothing,
// so the dimmed child shows through.
final dismissLayer = dismissible
? GestureDetector(onTap: () => onDismiss?.call(), child: Container())
: Container();
return Stack(
fit: StackFit.expand,
alignment: Alignment.center,
children: [
blockedBackground,
dismissLayer,
Center(child: FocusScope(isTrapped: true, child: dialog)),
],
);
}