SecurityService class

Service for handling security-related features.

This service provides utilities for:

  • Auto-clearing PIN after inactivity
  • Screenshot blocking (platform-specific)
  • Secure input handling
  • Rate limiting for failed attempts

Example usage:

final service = SecurityService();
service.startAutoClearTimer(
  timeout: Duration(seconds: 30),
  onTimeout: () {
    // Clear PIN after 30 seconds of inactivity
  },
);

Constructors

SecurityService()

Properties

failedAttempts int
Gets the number of failed attempts.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

disableScreenshotBlocking() Future<bool>
Disables screenshot blocking.
dispose() → void
Cleans up resources.
enableScreenshotBlocking() Future<bool>
Enables screenshot blocking on supported platforms.
getTimeUntilRateLimitLifted({int maxAttempts = 5, Duration timeWindow = const Duration(minutes: 15)}) Duration?
Gets the time until rate limiting is lifted (if currently rate limited).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
recordFailedAttempt() → void
Records a failed authentication attempt.
recordSuccessfulAttempt() → void
Records a successful authentication attempt.
resetAutoClearTimer() → void
Resets the auto-clear timer.
shouldRateLimit({int maxAttempts = 5, Duration timeWindow = const Duration(minutes: 15)}) bool
Checks if authentication should be rate limited.
startAutoClearTimer({required Duration timeout, required VoidCallback onTimeout}) → void
Starts an auto-clear timer that will call onTimeout after timeout duration of inactivity.
stopAutoClearTimer() → void
Stops the auto-clear timer.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited