getMonotonicTimeMillis method

  1. @override
Future<int?> getMonotonicTimeMillis()
override

Returns platform monotonic elapsed time in milliseconds when available.

The value must not be affected by manual wall-clock changes. Implementations may return null when monotonic time is unavailable.

Implementation

@override
Future<int?> getMonotonicTimeMillis() async {
  try {
    final result = await methodChannel.invokeMethod<Object?>(
      'getMonotonicTimeMillis',
    );
    if (result is int) {
      return result;
    }
    if (result is num) {
      return result.toInt();
    }
    return null;
  } on MissingPluginException {
    return null;
  } catch (e) {
    safeLog('Failed to get platform monotonic time', error: e);
    return null;
  }
}