Skip to content

Commit b0394cc

Browse files
committed
expiration
1 parent 174a6c5 commit b0394cc

3 files changed

Lines changed: 25 additions & 11 deletions

File tree

lib/services/api_service.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ class ApiService {
250250
headers: permissionHeaders,
251251
body: permissionBody,
252252
);
253-
return 'https://eta.fleetmap.io/?token=$token';
253+
final exp = Uri.encodeComponent(expirationTime.toUtc().toIso8601String());
254+
return 'https://eta.fleetmap.io/?token=$token&expiration=$exp';
254255
} catch (e, stack) {
255256
dev.log('Error in shareDevice: $e', name: 'API', error: e, stackTrace: stack);
256257
return '';
@@ -271,7 +272,8 @@ class ApiService {
271272
);
272273

273274
if (response.statusCode == 200) {
274-
final url = "https://fleetmap-io.github.io/share-vehicle-location?token=${response.body}";
275+
final exp = Uri.encodeComponent(expiration.toUtc().toIso8601String());
276+
final url = "https://fleetmap-io.github.io/share-vehicle-location?token=${response.body}&expiration=$exp";
275277
dev.log(url);
276278
return url;
277279
} else {

lib/widgets/device_detail.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,24 @@ class DeviceDetail extends StatelessWidget {
162162
Future<void> _shareLocation(BuildContext context) async {
163163
if (position == null) return;
164164

165+
final now = DateTime.now();
166+
final pickedDate = await showDatePicker(
167+
context: context,
168+
initialDate: now.add(const Duration(days: 1)),
169+
firstDate: now,
170+
lastDate: now.add(const Duration(days: 365)),
171+
);
172+
if (pickedDate == null) return;
173+
if (!context.mounted) return;
174+
175+
final expiration = DateTime(pickedDate.year, pickedDate.month, pickedDate.day, 23, 59, 59);
176+
165177
final apiService = ApiService();
166178

167179
try {
168-
final expiration = DateTime.now().add(const Duration(hours: 24));
169180
String? shareUrl = await apiService.shareDevice(device.id, expiration);
170181
if (shareUrl.isEmpty) {
182+
if (!context.mounted) return;
171183
shareUrl = await apiService.shareDeviceV2(device.id, expiration);
172184
}
173185
if (shareUrl == null || shareUrl.isEmpty) throw Exception('No share URL');

pubspec.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ packages:
4545
dependency: transitive
4646
description:
4747
name: characters
48-
sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
48+
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
4949
url: "https://pub.dev"
5050
source: hosted
51-
version: "1.4.1"
51+
version: "1.4.0"
5252
checked_yaml:
5353
dependency: transitive
5454
description:
@@ -409,18 +409,18 @@ packages:
409409
dependency: transitive
410410
description:
411411
name: matcher
412-
sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6"
412+
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
413413
url: "https://pub.dev"
414414
source: hosted
415-
version: "0.12.18"
415+
version: "0.12.17"
416416
material_color_utilities:
417417
dependency: transitive
418418
description:
419419
name: material_color_utilities
420-
sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b"
420+
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
421421
url: "https://pub.dev"
422422
source: hosted
423-
version: "0.13.0"
423+
version: "0.11.1"
424424
meta:
425425
dependency: transitive
426426
description:
@@ -662,10 +662,10 @@ packages:
662662
dependency: transitive
663663
description:
664664
name: test_api
665-
sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636"
665+
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
666666
url: "https://pub.dev"
667667
source: hosted
668-
version: "0.7.9"
668+
version: "0.7.7"
669669
typed_data:
670670
dependency: transitive
671671
description:

0 commit comments

Comments
 (0)