DatetimeValidator class
A singleton class that validates the device's current time by comparing it with the accurate network time (NTP).
Use isDateTimeValid to check if the device time is within an acceptable range.
Constructors
- DatetimeValidator()
-
Returns the singleton instance of DatetimeValidator.
factory
-
DatetimeValidator.forTesting({required ILocalDataSource localDataSource, required Future<
DateTime> networkTimeProvider(), required Future<int?> monotonicTimeProvider(), required DateTime deviceTimeProvider()}) -
Creates a validator with injectable dependencies for tests.
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- localDataSource → ILocalDataSource
-
Used to get and store network time locally.
final
- networkTime ↔ DateTime?
-
The network time used as the reference to validate the device's current time.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getNetworkTime(
) → Future< DateTime?> - Fetches the current network time using NTP. Falls back to monotonic-adjusted cached NTP time if fetching fails.
-
isDateTimeValid(
{int toleranceInSeconds = 86400}) → Future< bool> - Validates the device's system time by comparing it with the network time (NTP).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited