Real-time tamper detection
Subscribe to listenToDateTimeChange to get instant callbacks whenever the user adjusts
the date, time, or timezone — even while the app is backgrounded.
Flutter Plugin
Install the plugin, validate device time against trusted NTP servers, and receive callbacks the moment a user or the OS adjusts the clock or timezone. Keep authentication windows, subscriptions, and monetization events accurate on every platform.
The plugin is designed for production workloads that cannot afford inaccurate device clocks. Each capability solves a specific pain point found in payment, gaming, compliance, and enterprise apps.
Subscribe to listenToDateTimeChange to get instant callbacks whenever the user adjusts
the date, time, or timezone — even while the app is backgrounded.
Compare device time against trusted NTP servers, validate against the drift tolerance you set, and gracefully handle network outages with cached timestamps.
Support mobile, desktop, and embedded Flutter runtimes with a single plugin. Time Guard works where your business logic runs.
Opt into structured logging to observe anomalies in production, feed dashboards, or pipe the events into your observability tooling.
Follow the core steps below to wire Flutter Time Guard into your application flow. Use the code blocks as a starting point and tighten the tolerance based on your business rules.
flutter pub add flutter_time_guard
Time Guard is null-safe, tested across Flutter stable channels, and adds no post-build configuration.
import 'package:flutter_time_guard/flutter_time_guard.dart';
Future<bool> isTimeValid() async {
FlutterTimeGuard.configureLogging(enableLogs: true);
return FlutterTimeGuard.isDateTimeValid(
toleranceInSeconds: 3600, // 1 hour drift tolerance
);
}
Call during authentication or before unlocking premium content. Pick a tolerance that prevents abuse without blocking legitimate users.
FlutterTimeGuard.listenToDateTimeChange(
stopListeingAfterFirstChange: true,
onTimeChanged: () async {
final isValid = await FlutterTimeGuard.isDateTimeValid(
toleranceInSeconds: 3600,
);
if (!isValid) {
// Show a blocking dialog, sign the user out, or notify your backend.
}
},
);
Re-validate inside the listener to filter out automatic OS synchronizations that keep the device within your allowed drift.
If your use case must fail closed when NTP is unreachable, store your own flag after the first successful validation and degrade functionality until the device time is corrected.
Clear answers for product managers, security teams, and Flutter engineers.
No. The plugin caches the most recent successful NTP lookup and reuses it when the device is offline,
falling back to true on first launch so legitimate users are not blocked.
Yes. Pass a custom servers list to isDateTimeValid or
configure to target internal or region-specific time authorities.
Start with one hour (3600 seconds) for general use cases. High-risk financial flows typically rely on 5–15 minute tolerances, while casual gaming can allow more drift for offline players.
Yes. Time Guard has no native dependencies that conflict with Firebase, Sentry, or popular analytics SDKs. Use the logging hooks to forward anomalies into your monitoring pipeline.