attachLongPress static method

void attachLongPress(
  1. BuildContext context, {
  2. String? userId,
})

Attach a global long-press gesture to open the logger overlay. Call this in your app's root widget (e.g., in build or initState).

Implementation

static void attachLongPress(BuildContext context, {String? userId}) {
  if (!_initialized) return;
  if (!config.value.enableLongPressGesture) return;
  if (!canAccess(userId: userId)) return;
  if (_overlayShown) return;

  final overlay = Overlay.of(context, rootOverlay: true);

  // Add a Listener to capture long-press anywhere
  WidgetsBinding.instance.addPostFrameCallback((_) {
    overlay.insert(
      OverlayEntry(
        builder: (ctx) => _LongPressDetector(
          onLongPress: () {
            if (_overlayShown) return;
            _showOverlay(context);
          },
        ),
      ),
    );
  });
}