为什么我不能在 datetime Flutter 项目中添加偏移时间?

问题描述

我现在尝试将偏移时间添加到我的日期时间对象中, 但它没有显示实际时间的添加时间。 这是我在android studio的flutter项目。

    void getTime() async {
    Response response = await
    get('http://worldtimeapi.org/api/timezone/Asia/Karachi');
    Map data = jsonDecode(response.body);
    String datetime = data['datetime'];
    String offset = data['utc_offset'].substring(1,3);

    print(offset);
    DateTime now = DateTime.parse(datetime);
    now.add(Duration(hours: int.parse('offset')));
    print(now);
    }
    @override
    void initState() {
    super.initState();
    getTime();
    }

这是我得到的结果: Screenshot of the output

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)