我如何仅将1微秒增加到dateTime.now()
我有以下
Dateime.now() + here i need to increase only 1 microsecond
想要的输出是dateime.now()
+ 1 microsecond
我尝试了以下
print(DateTime.now()+const Duration(microsecond : 1);)
内容
i have the following
Dateime.now() + here i need to increase only 1 microsecond
so wanted output is Dateime.now()
+ that incensement which is 1 microsecond
i tried the following but it does not work
print(DateTime.now()+const Duration(microsecond : 1);)
How can i implement this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这很好地完成了。
检查文档在这里
或在一行中进行:
This well get it done.
check docs here
Or do it in a single line:
dateTime
不能定义操作员 +
,但它确实具有
。)添加
方法接受持续时间
。 (您的代码中还有几个语法错误;分号是放错了位置,命名参数为持续时间
是microseconds
,而不是microsecond
另请参阅: https://stackoverflow.com/a/a/607477710/
DateTime
does not define anoperator +
, but it does have anadd
method that accepts aDuration
. (You also have a couple of syntax errors in your code; the semicolon is misplaced, and the named parameter toDuration
ismicroseconds
, notmicrosecond
.)If you're testing with Dart for the Web (such as with DartPad), you will not get microsecond precision due to limitations with JavaScript. Running the following code in the Dart VM will show a change in microseconds:
Also see: https://stackoverflow.com/a/60747710/