【问题标题】:Flutter on Android emulator showing incorrect DateTime.now()Android 模拟器上的颤振显示不正确的 DateTime.now()
【发布时间】:2021-06-27 08:18:31
【问题描述】:

模拟器时区与系统时区相同,但 Flutter 的 DateTime.now() 返回的是 GMT 时间。

以下代码中的问候语应该是“下午好”。当地时间是15:23


详情:

颤振/飞镖:

颤振--版本
Flutter 2.0.3 • 通道稳定 • https://github.com/flutter/flutter.git
框架 • 修订 4d7946a68d(12 天前) • 2021-03-18 17:24:33 -0700
引擎 • 修订版 3459eb2436
工具• Dart 2.12.2

模拟器:

Android 7.0(牛轧糖)上的 Nexus 5X - API 24
模拟器版本:30.5.3-7196367

系统:

Microsoft Windows 10 专业版 10.0.15063 构建 15063

VS 代码:

版本:1.54.3(用户设置)
电子:11.3.0
铬:87.0.4280.141
Node.js:12.18.3
V8:8.7.220.31-electron.0
操作系统:Windows_NT x64 10.0.15063

【问题讨论】:

  • @Anna:我已经试过了。模拟器时区是正确的,您可以看到手机顶部状态栏中的时间是15:23,与我的系统时间相匹配,但应用程序内的时间是09:51
  • 尝试了确切的代码并在模拟器中正常工作
  • @MidhunMP:谢谢,我收到了我应该尝试不同的模拟器的提示。有效!检查我的解决方案。

标签: flutter datetime dart android-emulator


【解决方案1】:

该错误似乎是 Nexus 5X Android 7.0 Nougat 模拟器特有的,并且代码在 Pixel 3a Android 11 模拟器上运行良好。

这是两个模拟器上的相同代码。截屏时当地时间为16:37,格林威治标准时间为11:07。两个模拟器都已设置为与系统相同的时区。

【讨论】:

    猜你喜欢
    • 2020-10-29
    • 2022-07-18
    • 2019-06-23
    • 1970-01-01
    • 1970-01-01
    • 2019-05-17
    • 1970-01-01
    • 2021-08-11
    • 1970-01-01
    相关资源
    最近更新 更多