forShareLocation method

void forShareLocation(
  1. KeyLocationModel notification
)

Implementation

void forShareLocation(KeyLocationModel notification) async {
  var atkeyMicrosecondId =
      notification.key!.split('sharelocation-')[1].split('@')[0];
  var acknowledgedKeyId = 'sharelocationacknowledged-$atkeyMicrosecondId';

  var allRegexResponses =
      await atClientInstance!.getKeys(regex: acknowledgedKeyId);

  // ignore: unnecessary_null_comparison
  if ((allRegexResponses != null) && (allRegexResponses.isNotEmpty)) {
    var acknowledgedAtKey = getAtKey(allRegexResponses[0]);

    var result = await atClientInstance!.get(acknowledgedAtKey).catchError(
        // ignore: return_of_invalid_type_from_catch_error
        (e) => print('error in get ${e.errorCode} ${e.errorMessage}'));

    var acknowledgedEvent =
        LocationNotificationModel.fromJson(jsonDecode(result.value));
    // ignore: unawaited_futures
    SharingLocationService()
        .updateWithShareLocationAcknowledge(acknowledgedEvent);
  }
}