最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

dart - Flutter: Web current time in microseconds has 3 zeros at left - Stack Overflow

programmeradmin3浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 2

Checkout 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()}',
    );
  }
}

发布评论

评论列表(0)

  1. 暂无评论