getEventDetails function

Future<EventNotificationModel?> getEventDetails(
  1. String key
)

This method retrieves the details of an event from the remote database using the provided event key It first obtains the regex key associated with the event key If the regex key is not found, it throws an exception The method then fetches the event data from the remote database and converts it into an EventNotificationModel object If the retrieval is successful, it returns the event data; otherwise, it returns null

Implementation

Future<EventNotificationModel?> getEventDetails(String key) async {
  EventNotificationModel eventData;
  String? regexKey;
  regexKey = await getRegexKeyFromKey(key);
  if (regexKey == null) {
    throw Exception('Event key not found');
  }
  try {
    var atkey = EventService().getAtKey(regexKey);
    var atvalue = await EventService()
        .atClientManager
        .atClient
        .get(atkey)
        .catchError((e) {
      print('error in get ${e.errorCode} ${e.errorMessage}');
      // ignore: invalid_return_type_for_catch_error
      return null;
    });
    eventData = EventNotificationModel.fromJson(jsonDecode(atvalue.value));
    return eventData;
  } catch (e) {
    return null;
  }
}