stopWatch static method
Creates a platform-optimized monotonic clock for measuring durations.
Use this factory to get a stopwatch to measure elapsed durations reliably, unaffected by system time changes.
Example:
final clock = Clock.stopWatch();
clock.start();
print('Elapsed: ${clock.duration()}');
Implementation
static StopWatchClock stopWatch() {
if (Platform.isAndroid) {
return NativeClock();
} else {
return DartClock();
}
}