getTrustedTimeWithAccuracy method

  1. @override
Future<TrustedTimeResult?> getTrustedTimeWithAccuracy()
override

Returns trusted UTC epoch time alongside an accuracy estimate.

Returns null if the GMS TrustedTime client is unavailable or has no time signal. The TrustedTimeResult.uncertaintyNanos field will be null on devices below Android 8.0 (API 26).

Implementation

@override
Future<TrustedTimeResult?> getTrustedTimeWithAccuracy() async {
  final Map<Object?, Object?>? data =
      await methodChannel.invokeMapMethod<Object?, Object?>(
    'getTrustedTimeWithAccuracy',
  );
  if (data == null) return null;

  return TrustedTimeResult(
    epochMillis: data['epochMillis'] as int,
    uncertaintyNanos: data['uncertaintyNanos'] as int?,
  );
}