local_session_timeout
3.2.0, released 2 years ago by sankethbk.me
Detects user inactivity or app background time and emits timeout events for redirection.
WASM-ready
What it does
Provides SessionConfig and SessionTimeoutManager widgets that monitor user activity and app focus. When configured durations are exceeded, a stream emits timeout states that can be used to navigate to an authentication page.
AI-written summary of version 3.2.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- The app contains confidential data and must auto‑logout after inactivity
- You need an offline‑first solution that works on mobile, web and desktop
- You want a simple, configurable timeout without adding a full auth framework
Skip it when
- Precise keyboard activity detection is required
- App‑focus timeout is needed on web or desktop (unsupported)
- You need a complete authentication solution rather than just timeout detection
Strengths
- Works offline and on all major platforms
- Simple API with configurable durations
- Uses a stream so you can react anywhere in the app
Weaknesses
- App‑focus timeout only works on Android/iOS
- Keyboard input isn’t counted as activity
- Must be placed at the top of the widget tree
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
import 'package:local_session_timeout/local_session_timeout.dart';
final sessionConfig = SessionConfig(
invalidateSessionForAppLostFocus: const Duration(seconds: 15),
invalidateSessionForUserInactivity: const Duration(seconds: 30),
);
sessionConfig.stream.listen((event) {
if (event == SessionTimeoutState.userInactivityTimeout) {
Navigator.of(context).pushNamed('/auth');
} else if (event == SessionTimeoutState.appFocusTimeout) {
Navigator.of(context).pushNamed('/auth');
}
});
return SessionTimeoutManager(
sessionConfig: sessionConfig,
child: MaterialApp(...),
);Alternatives
Packages that do the same job and could replace local_session_timeout.
- flutter_background_service_platform_interface
Platform interface for flutter_background_service plugin
50Compare