showOverlay<T> method
The alignment priority is higher than the others. To remove an overlay use the following code: overlayEntry.remove(); overlayEntry.dispose();
Implementation
OverlayEntry showOverlay<T>({
required Widget child,
Alignment? alignment,
double? fromTop,
double? fromBottom,
double? fromRight,
double? fromLeft,
bool canSizeOverlay = false,
bool maintainState = false,
bool opaque = false,
}) {
OverlayEntry overlayEntry = OverlayEntry(
canSizeOverlay: canSizeOverlay,
maintainState: maintainState,
opaque: opaque,
builder: (context) {
return Stack(
children: [
Positioned(
top: fromTop,
bottom: fromBottom,
right: fromRight,
left: fromLeft,
child: Material(
type: MaterialType.transparency,
child: Container(
alignment: alignment,
child: child,
),
),
),
],
);
},
);
Overlay.of(context, debugRequiredFor: child).insert(overlayEntry);
return overlayEntry;
}