TrueTime颤振

时间:2019-03-07 09:17:33

标签: dart flutter

我正在实现实时抖动库https://pub.dartlang.org/packages/true_time

遇到错误

W/DiskCacheClient(26153): Cannot use disk caching strategy for TrueTime.

 CacheInterface unavailable
D/TrueTimeRx(26153): ---- resolving ntpHost : ntp.google.com
W/DiskCacheClient(26153): Cannot use disk caching strategy for TrueTime. CacheInterface unavailable
E/MethodChannel#true_time(26153): Failed to handle method call
E/MethodChannel#true_time(26153): java.lang.IllegalStateException: You need to call init() on TrueTime at least once.

我从上面链接到自述文件的代码副本中得到了此错误。

3 个答案:

答案 0 :(得分:1)

您尝试使用此库吗?它仅使用dart代码,而不使用平台通道。 https://pub.dartlang.org/packages/ntp

您可以这样获得时间:

DateTime startDate = await NTP.now();

免责声明:我是这个库的开发者。

答案 1 :(得分:0)

您可以发布代码吗?从堆栈跟踪中可以明显看出,您没有origin/develop TrueTime。在https://pub.dartlang.org/packages/true_time的示例中,您可以看到它们具有以下代码

init

答案 2 :(得分:0)

它应该是time.google.com作为NTP主机,而不是ntp.google.com库中的true_time。 您可以直接从软件包中使用true_time.dart并将ntp主机更新为time.google.com以使其正常工作。

相关问题