Use window.performance.now()to get high resolution monotonous time. The function now()returns a colon with microseconds in fractional.
Here is an example:
import 'dart:html';
main() {
var time = window.performance.now();
print(time); // 12123.24341221
}
Please note that now()this is not a typical “time from the era”. Instead it is a delta from window.performance.timing.navigationStart.
The field is navigationStartdefined as (from spec ):
. , , fetchStart.
window.performance.now() , , DateTime.
requestAnimationFrame ( , ?), !
, animationFrame, :
Future<num> animationFrame;
:
gameLoop(num highResolutionTime) {
// stuff
window.animationFrame.then(gameLoop);
}
main() {
window.animationFrame.then(gameLoop);
}