showFloatingWidget static method
      
void
showFloatingWidget(})
      
     
    
    
Implementation
static void showFloatingWidget(
  BuildContext context, {
  String? title,
  String? body,
  String? background,
  String? textColor,
  String? url,
  String? position,
  int? scale,
  bool isDraggable = false,
  Widget? customWidget,
  void Function()? onTap,
  bool? isVisible = false,
}) {
  // Remove existing widget if any
  _entry?.remove();
  _entry = null;
  if (!(isVisible ?? false)) return;
  final overlay = Overlay.of(context);
  final screenSize = MediaQuery.of(context).size;
  const double margin = 30;
  Offset currentOffset;
  switch (position?.toLowerCase()) {
    case "topleft":
      currentOffset = const Offset(margin, margin);
      break;
    case "topcenter":
    case "top":
      currentOffset = Offset((screenSize.width - margin * 6) / 2, margin);
      break;
    case "topright":
      currentOffset = Offset(screenSize.width - margin * 6, margin);
      break;
    case "bottomleft":
      currentOffset = Offset(margin, screenSize.height - margin * 6);
      break;
    case "bottomcenter":
    case "bottom":
      currentOffset = Offset((screenSize.width - margin * 6) / 2,
          screenSize.height - margin * 6);
      break;
    case "bottomright":
      currentOffset = Offset(
          screenSize.width - margin * 6, screenSize.height - margin * 6);
      break;
    case "center":
      currentOffset = Offset((screenSize.width - margin * 6) / 2,
          (screenSize.height - margin * 5) / 2);
      break;
    case "leftcenter":
    case "left":
      currentOffset = Offset(margin, (screenSize.height - margin * 5) / 2);
      break;
    case "rightcenter":
    case "right":
      currentOffset = Offset(screenSize.width - margin * 6,
          (screenSize.height - margin * 5) / 2);
      break;
    default:
      currentOffset = Offset((screenSize.width - margin * 6) / 2,
          screenSize.height - margin * 6);
  }
  _entry = OverlayEntry(
    builder: (context) {
      return StatefulBuilder(
        builder: (context, setState) {
          return Positioned(
            top: currentOffset.dy,
            left: currentOffset.dx,
            child: SafeArea(
              child: Material(
                elevation: 0,
                color: Colors.transparent,
                child: GestureDetector(
                  onTap: onTap,
                  onPanUpdate: (details) {
                    if (isDraggable) {
                      setState(() {
                        currentOffset += details.delta;
                      });
                    }
                  },
                  child: customWidget ??
                      Container(
                        width: screenSize.width * 0.4,
                        padding: const EdgeInsets.all(10),
                        decoration: BoxDecoration(
                          color: background != null
                              ? Util.hexToColor(background)
                              : Util.isDarkMode
                                  ? Colors.black
                                  : Colors.white,
                          borderRadius: BorderRadius.circular(8),
                          boxShadow: const [
                            BoxShadow(
                              color: Colors.black26,
                              blurRadius: 10,
                              offset: Offset(2, 2),
                            ),
                          ],
                        ),
                        child: Column(
                          mainAxisSize: MainAxisSize.min,
                          children: [
                            if (title != null)
                              Text(
                                title,
                                style: TextStyle(
                                  fontSize: 18,
                                  fontWeight: FontWeight.bold,
                                  color: textColor != null
                                      ? Util.hexToColor(textColor)
                                      : null,
                                ),
                              ),
                            const SizedBox(height: 8),
                            if (WebviewUtil.controller != null)
                              WebviewUtil.getWebViewWidget(
                                body,
                                textColor,
                                null,
                              )
                          ],
                        ),
                      ),
                ),
              ),
            ),
          );
        },
      );
    },
  );
  overlay.insert(_entry!);
  if (WebviewUtil.controller != null) {
    WebviewUtil.load(
      url,
      htmlBodyStart + body.toString() + htmlBodyEnd,
    );
  }
}