SankethBK / local_session_timeout

Redirect user to authentication page if the application doesn't receive any user interaction, or been running in the background for "x" duration.
https://pub.dev/packages/local_session_timeout
BSD 3-Clause "New" or "Revised" License
12 stars 19 forks source link

Added keyboard and mouse scroll listener for web and desktop app #34

Closed Kuroketsu closed 2 months ago

Kuroketsu commented 2 months ago

Added keyboard and mouse scroll listener for web and desktop app

@override
  Widget build(BuildContext context) {
    // Attach Listener only if user wants to invalidate session on user inactivity
    if (widget._sessionConfig.invalidateSessionForUserInactivity != null) {
      return Listener(
        onPointerDown: (_) {
          recordPointerEvent();
        },
        onPointerSignal: (pointerSignal) {
          if (pointerSignal is PointerScrollEvent) {
            recordPointerEvent();
          }
        },
        child: KeyboardListener(
          focusNode: _focusNode,
          onKeyEvent: (_) {
            recordPointerEvent();
          },
          child: widget.child,
        ),
      );
    }

    return widget.child;
  }
SankethBK commented 2 months ago

Thanks for contributing! I'll review it by tomorrow