From 933040d8d91ca4620a6dd6430c14cae65466e279 Mon Sep 17 00:00:00 2001 From: Mochamad Nizwar Syafuan Date: Mon, 22 Jul 2024 03:19:14 +0700 Subject: [PATCH] Update datetime is nulled regarding vpn status --- lib/src/vpn_engine.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/vpn_engine.dart b/lib/src/vpn_engine.dart index 3390a3c..4fb2cab 100644 --- a/lib/src/vpn_engine.dart +++ b/lib/src/vpn_engine.dart @@ -196,7 +196,8 @@ class OpenVPN { var data = jsonDecode(value); var connectedOn = DateTime.tryParse(data["connected_on"].toString()) ?? - _tempDateTime; + _tempDateTime ?? + DateTime.now(); String byteIn = data["byte_in"] != null ? data["byte_in"].toString() : "0"; String byteOut = @@ -205,8 +206,7 @@ class OpenVPN { if (byteOut.trim().isEmpty) byteOut = "0"; return VpnStatus( connectedOn: connectedOn, - duration: - _duration(DateTime.now().difference(connectedOn!).abs()), + duration: _duration(DateTime.now().difference(connectedOn).abs()), byteIn: byteIn, byteOut: byteOut, packetsIn: byteIn,