GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - PSCHKLLR/flutter_true_time: ​A Flutter plugin for fetching true network time via NTP, preventing device clock manipulation on Android and iOS.

BranchesTags
Open more actions menu

Latest commit

 

History

53 Commits
53 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.vscode
.vscode
 
 
android
android
 
 
docs
docs
 
 
example
example
 
 
lib
lib
 
 
test
test
 
 
test_flutter
test_flutter
 
 
tool
tool
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.pubignore
.pubignore
 
 
AGENTS.md
AGENTS.md
 
 
ARCHITECTURE.md
ARCHITECTURE.md
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
THIRD_PARTY_NOTICES.md
THIRD_PARTY_NOTICES.md
 
 
analysis_options.yaml
analysis_options.yaml
 
 
pubspec.lock
pubspec.lock
 
 
pubspec.yaml
pubspec.yaml
 
 

Repository files navigation

flutter_true_time

pub.dev version GitHub release

Network-derived UTC timestamps for Flutter, anchored to a monotonic clock with explicit freshness and uncertainty. See pub.dev for published versions.

This is an independently maintained rebuild of the trusted_time design/API baseline. It is not a drop-in replacement or an official upstream release. Historical license and NOTICE attribution is preserved in THIRD_PARTY_NOTICES.md.

Use in a Flutter app

Version 2.0.0 uses the TrueTime API. Versions through 1.0.0 use TrustedTime, TrustedTimeEngine, TrustedTimeConfig, and TrustedTimeException. See the migration guide for the breaking rename.

Add the package to your Flutter app:

dependencies:
  flutter_true_time: ^2.0.0
import 'package:flutter/widgets.dart';
import 'package:flutter_true_time/flutter_true_time.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await TrueTime.initialize(
    persistence: PersistenceConfig(namespace: 'com.example.my_app'),
  );
  // Initialization starts a sync; it does not imply readiness.
  try {
    await TrueTime.waitUntilReady();
    final reading = TrueTime.read();
    debugPrint(reading.utc.toIso8601String());
    debugPrint('Estimated uncertainty: ' + reading.uncertainty.toString());
  } on TrueTimeException catch (error) {
    debugPrint(error.code); // Retry/show unavailable; never substitute system time.
  }
}

Omit persistence for an in-memory clock. Use an application-specific namespace and one writer per namespace/isolate; share an AnchorStore object when multiple engines intentionally share state. The Android bridge declares INTERNET permission through its library manifest. Sandboxed macOS applications need the network client entitlement.

Foreground startup attempts restoration and fresh synchronization concurrently. Fresh readiness does not wait for epoch/storage I/O, and valid restored state can also satisfy readiness early. Initialization completes after its bounded restoration attempt and does not imply readiness; use waitUntilReady() for the independent readiness wait.

Native defaults query time.cloudflare.com and ntp.netnod.se (distinct configured provider labels). Network/server policies may prevent consensus. These servers are external services, and the labels do not cryptographically prove operational independence. See Cloudflare and Netnod.

Read contract

API Result
now(), nowUnixMs(), nowIso() Strict UTC; throws when unavailable or stale
read() UTC, uncertainty, anchor age, source/provider evidence, and restored origin; throws when unavailable
estimate() Labeled ready/stale reading, or null without a continuous anchor
waitUntilReady() Bounded wait returning the same reading sampled as ready, including restored anchors
forceResync() One shared bounded cycle; a replacement is queued after invalidation
status / events Availability, sync state, failures, restoration, and clock diagnostics
dispose() Releases timers/observation and cancels owned transport work

UTC may move backward after a correction. Use a monotonic timer for durations; these timestamps do not provide unique IDs or globally ordered events.

Foreground availabilityChanged events include scheduled age/drift expiry, even without reads or automatic refresh. Background delivery can be delayed; resume resamples availability. Clock sampling failures and error-bound changes require a subsequent snapshot to discover. See the expiry contract.

Defaults remain: 30-minute foreground refresh, 3-second source timeout, 5-second cycle deadline, two sources from two named providers, 24-hour anchor-age limit, 5-second uncertainty limit, and 100-ppm drift budget. Uncertainty grows by 360 ms per offline hour at that budget, in addition to sampling and source error. This is an engineering estimate under stated assumptions, not an accuracy or security guarantee.

TrueTimeConfig.maximumUncertainty is the portable arithmetic limit (9007199254740991 microseconds). Values or projected bounds beyond it fail explicitly with uncertain; representable bounds above your configured policy remain stale estimates. A schedulingFailed event means automatic refresh/retry or diagnostic registration failed. The completed network result and anchor are retained; a later sync retries refresh registration and resume retries diagnostic registration.

Up to 1,024 sources (TrueTimeEngine.maximumSources) are supported; larger lists fail at construction. The sync deadline stops collection, including immediate-source chains. Previously accepted evidence may finish bounded consensus and queue persistence afterward; synchronous custom callbacks cannot be preempted. See the deadline contract and scaling measurements.

Persistence capability

Platform Clock Offline restore after app restart
Android API 24+ CLOCK_BOOTTIME Only with matching boot count, no-backup installation marker, clock domain, and trust policy
Linux CLOCK_BOOTTIME Only with a matching kernel boot UUID and application scope
iOS/macOS mach_continuous_time Fresh online sync required by the default provider
Windows QueryPerformanceCounter Fresh online sync required by the default provider
Web Session-only portable clock Fresh online sync after page/browser restart

A reboot never authorizes reuse by comparing uptime alone. Missing epoch evidence, changed policy, expired/corrupt records, inaccessible storage, and restored backup mismatches fail closed. Apple removed app access to the iOS boot-session UUID; secure storage does not supply that proof.

Storage keeps one active write and at most one pending complete record per shared backend. The newest pending record replaces older pending work; replaced saves fail with storageSuperseded and engines report storageFailed, while the in-memory clock remains usable. Caller timeout or disposal does not release the active writer; it proceeds to the newest pending record only after the backend settles. See the persistence contract for completion, shared-policy, and load ordering semantics. Opaque third-party sources that ignore cancellation retain their concurrency permit until their real Future settles.

Browser setup

Supply at least two independently operated HttpsDateSource endpoints. Each must support HEAD, normal TLS verification, a Date header, Cache-Control: no-store, absent/zero Age, and CORS-exposed Date/Cache-Control/Age headers. Redirects, cached replies, and missing evidence are excluded.

The demo accepts TRUE_TIME_HTTPS_A, TRUE_TIME_HTTPS_B, TRUE_TIME_PROVIDER_A, and TRUE_TIME_PROVIDER_B dart-defines. Missing browser configuration reports sourcesRequired instead of inventing trusted time.

Development and compatibility

The minimum declared SDK is Flutter 3.41.0 / Dart 3.11.0. The qualification lanes pin Flutter 3.41.0 and 3.47.9. See the compatibility matrix and validation record for platform evidence.

flutter pub get
flutter analyze
flutter test test test_flutter --coverage
dart test test
cd example
flutter run -d windows

The Flutter-independent engine is exported from core.dart. Inject MonotonicClock, TimeSource, BootEpochProvider, AnchorStore, TimeScheduler, and WallClockReader for deterministic tests. Custom sources must expose an immutable configurationKey and honor CancellationSignal to release resources promptly.

No NTS authentication, TLS bypass, system-clock modification, untrusted wall-clock fallback, or OS-managed background worker is included. See the specification, migration guidance, and release procedures.

Release tooling lives in the repository. dart run tool/release.dart patch previews a version bump. Create a release branch and add --write to prepare the four release files, then review, commit, push the branch, and open a PR to main. Pass the required checks, resolve conversations, and merge. After explicit publication authorization, run dart run tool/release.dart current --publish from clean, updated main to tag the merged version. See the release procedure.

dart run tool/update_release_manifest.dart records the tracked source digest, and dart run tool/release_check.dart checks the matching qualification evidence. The full candidate check also runs the pinned Pub dry run in the isolated candidate. See the device and browser procedures.

About

​A Flutter plugin for fetching true network time via NTP, preventing device clock manipulation on Android and iOS.

pub.dev/packages/flutter_true_time

Topics

clock-driftcross-platformdartflutterflutter-packageflutter-pluginflutter-true-timemonotonic-clocknetwork-timenetwork-time-protocolntptime-synctime-synchronizationtimestamptrue-timetruetimeutc

Resources

Readme
MIT license

Security policy

Security policy
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.