I create this widget as an workaround until FF implement the official one. Put this widget in the page where you need user inactivity timeout, set the "timeoutDuration" parameter and it will do the job (return to HomePage after "timeoutDuration" seconds if the user has no activity)
[image.png] import 'dart:async';
class SessionTimer extends StatefulWidget {
const SessionTimer({
Key key,
this.width,
this.height,
this.timeoutDuration,
this.minTimeoutDuration,
}) : super(key: key);
final double width;
final double height;
final int timeoutDuration;
final int minTimeoutDuration;
@override
_SessionTimerState createState() => _SessionTimerState();
}
class _SessionTimerState extends State {
Timer _timer;
void _handleInactivity(){
Navigator.pushReplacementNamed(context, "/");
}
void _initializeTimer() {
if (_timer != null) {
_timer.cancel();
}
// setup action after "timeoutDuration"
_timer = Timer(Duration(seconds: widget.timeoutDuration < widget.minTimeoutDuration ? widget.minTimeoutDuration : widget.timeoutDuration), () => _handleInactivity());
}
void _handleUserInteraction([_]) {
_initializeTimer();
print(_); print(" Detected! Reset timer ...\n");
}
@override
Widget build(BuildContext context) {
return GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () => _handleUserInteraction("onTap"),
onPanDown: _handleUserInteraction,
child: Container()
);
}
}