class Geoposition { final String id; final double xValue; final double yValue; final DateTime lastUpdate; final DateTime expiresAt; Geoposition({ required this.id, required this.xValue, required this.yValue, required this.lastUpdate, required this.expiresAt, }); Map toJson() { return { 'id': id, 'x': xValue, 'y': yValue, 'lastUpdate': lastUpdate.toIso8601String(), 'remainingSeconds': expiresAt.difference(DateTime.now()).inSeconds, }; } factory Geoposition.fromMap(Map map) { return Geoposition( id: map['id'], xValue: map['x_value'].toDouble(), yValue: map['y_value'].toDouble(), lastUpdate: map['last_update'] as DateTime, expiresAt: map['expires_at'] as DateTime, ); } }