【问题标题】:Is it possible to have a time interval in Flutter?Flutter中是否可以有时间间隔?
【发布时间】:2022-11-04 19:46:44
【问题描述】:

我想知道是否有任何方法可以获取 Flutter 中某个项目的时间间隔?

例子:

我有一个项目,我在其中设置了上次校准该项目的日期,然后我希望应用程序在设定的时间段后提醒我(通过推送消息或电子邮件)进行下一次校准,依此类推。

我将Firestore 用于我的数据库。

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    你可能想看看Duration飞镖的课。

    文档:https://api.dart.dev/stable/2.18.4/dart-core/Duration-class.html

    为了给你一个想法,快速的代码示例来初始化一个时间跨度:

    const fastestMarathon = Duration(hours: 2, minutes: 3, seconds: 2);
    print(fastestMarathon.inDays); // 0
    print(fastestMarathon.inHours); // 2
    print(fastestMarathon.inMinutes); // 123
    print(fastestMarathon.inSeconds); // 7382
    print(fastestMarathon.inMilliseconds); // 7382000
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-31
      • 2018-02-14
      • 2021-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多