getEvents method

Future<void> getEvents(
  1. int newType
)

Implementation

Future<void> getEvents(int newType) async {
  Map<String, dynamic> params = <String, dynamic>{};
  String upcomingDays = '0';
  String type = newType.toString();

  try {
    final response = await _apiService.getData(
        '${AppUrls.getBirthdays}/2024-11-11/$upcomingDays/$type',
        queryParams: params);
    if (response.statusCode == 200) {
      final List<dynamic> jsonData = response.data['data'];
      final modelResponse = EventsResponse.fromDecodedJsonList(jsonData);
      eventsList.value = modelResponse;
    } else {
      notificationCount.value = 0;
      print('Failed to load ');
    }
  } catch (e, stackTrace) {
    print('Failed to stackTrace ' + stackTrace.toString());
    debugPrint('Error in getEvents: $e');
  }
}