getHybridModel method
// Explanation:
/ locationReceivedData will contain locationDataModel for atsigns
{'atsign': locationDataModel}
And for each user (atsign) we will store their HybridModel in _allReceivedUsersList
{'atsign': HybridModel}
when we want the location of a user we will query in the _locationReceivedData map
with the atsign and event/p2p id
if the atsign is present
then we will look into locationSharingFor value of the _locationReceivedData'atsign'
if the event/p2p id is present in locationSharingFor value
and DateTime.now() is between from and to of the locationSharingFor value
then we will return the HybridModel of the atsign in _allReceivedUsersList
Retrieves the HybridModel for a given Atsign and optional id
Implementation
/// Retrieves the HybridModel for a given Atsign and optional id
HybridModel? getHybridModel(String atsign, {String? id}) {
if (id != null) {
id = trimAtsignsFromKey(id);
if ((_locationReceivedData[atsign] != null) &&
(_locationReceivedData[atsign]!.locationSharingFor[id] != null)) {
var _locationSharingFor =
_locationReceivedData[atsign]!.locationSharingFor[id];
if ((_locationSharingFor!.isAccepted) &&
(_locationSharingFor.isSharing) &&
(_locationSharingFor.from != null &&
_locationSharingFor.to != null) &&
(DateTime.now().isAfter(_locationSharingFor.from!)) &&
(DateTime.now().isBefore(_locationSharingFor.to!))) {
if (_allReceivedUsersList[atsign]!.latLng == null) {
return null;
}
return _allReceivedUsersList[atsign];
}
}
return null;
} else {
/// for calls that don't pass an id (dont need data specific to any event/p2p)
return _allReceivedUsersList[atsign];
}
}