getApplications method

Future<List<Announcement>?> getApplications({
  1. String? locale,
  2. GeneralCallback<List<Announcement>?>? callback,
})

Implementation

Future<List<Announcement>?> getApplications({
  String? locale,
  GeneralCallback<List<Announcement>?>? callback,
}) async {
  try {
    final Response<Map<String, dynamic>> response = await dio.get(
      '/application',
    );
    AnnouncementData data = AnnouncementData(data: <Announcement>[]);
    if (response.statusCode != 204) {
      data = AnnouncementData.fromJson(response.data!);
      data.data.sort((Announcement a, Announcement b) {
        return b.weight.compareTo(a.weight);
      });
    }
    if (callback != null) {
      callback.onSuccess(data.data);
    }
    return data.data;
  } on DioError catch (dioError) {
    if (callback == null) {
      rethrow;
    } else {
      callback.onFailure(dioError);
    }
  }
  return null;
}