In Flutter web, this code return an int with 3 trailing zeros.
Date = DateTime.now().microsecondsSinceEpoch
Is there no precise way to return the current time in microseconds on the web?
In Flutter web, this code return an int with 3 trailing zeros.
Date = DateTime.now().microsecondsSinceEpoch
Is there no precise way to return the current time in microseconds on the web?
Share Improve this question edited Mar 19 at 10:33 Frank van Puffelen 601k85 gold badges890 silver badges860 bronze badges asked Mar 19 at 8:09 Rami DhouibRami Dhouib 494 bronze badges1 Answer
Reset to default 2Checkout window.performance.now()
from web.dart
here the comparison between Datetime
and Stopwatch
import 'package:web/web.dart';
void main() {
var sw = new Stopwatch()..start();
for (var i = 0; i < 10; i++) {
print(
'hello ${i + 1}: ${sw.elapsed} and ${DateTime.now().microsecondsSinceEpoch} further ${window.performance.now()}',
);
}
}