addAnnouncement method Null safety

Future<Response?> addAnnouncement(
  1. {required Announcement data,
  2. GeneralCallback<Response>? callback,
  3. String? languageCode}
)

Implementation

Future<Response<dynamic>?> addAnnouncement({
  required Announcement data,
  GeneralCallback<Response<dynamic>>? callback,
  String? languageCode,
}) async {
  try {
    data.tags ??= <String>[];
    data.tags!.addAll(
      <String?>[
        languageCode ?? 'zh',
        if (organization != null) organization,
      ],
    );
    final Response<dynamic> response = await dio.post(
      '/announcements/add',
      data: data.toUpdateJson(),
    );
    if (callback != null) {
      callback.onSuccess(response);
    }
    return response;
  } on DioError catch (dioError) {
    if (callback == null) {
      rethrow;
    } else {
      handleCrudError(dioError, callback);
    }
  }
  return null;
}