showBeacon static method
void
showBeacon(
- BuildContext context, {
- required String shape,
- required GlobalKey<
State< key,StatefulWidget> > - required String beaconPosition,
- String? title,
- required String body,
- required Color color,
- required dynamic onBeaconClicked(),
Implementation
static void showBeacon(
BuildContext context, {
required String shape,
required GlobalKey key,
required String beaconPosition,
String? title,
required String body,
required Color color,
required Function() onBeaconClicked,
}) {
// Get the render box for the target widget
final RenderBox renderBox =
key.currentContext!.findRenderObject() as RenderBox;
final size = renderBox.size;
final position = renderBox.localToGlobal(Offset.zero);
Offset beaconOffset =
calculateBeaconPosition(beaconPosition, position, size);
// Use an OverlayEntry to display the pulse animation
final overlay = Overlay.of(context);
OverlayEntry? entry;
entry = OverlayEntry(
builder: (context) => Positioned(
top: beaconOffset.dy, // Calculated top position
left: beaconOffset.dx, // Calculated left position
child: GestureDetector(
child: PulseAnimation(
color: color,
),
onTap: () {
entry!.remove();
showTooltip(
context,
key: key,
shape: shape,
title: title,
body: body,
);
onBeaconClicked();
},
),
),
);
overlay.insert(entry);
// Remove the overlay after a delay
// Future.delayed(Duration(seconds: 3), () {
// entry.remove();
// });
}