followBackOrUnfollow function

Future<String> followBackOrUnfollow(
  1. {required int userId,
  2. required bool isUnfollow}
)

Implementation

Future<String> followBackOrUnfollow({required int userId, required bool isUnfollow}) async {
  appStore.setLoading(true);

  Map req = {FriendKey.followers: appStore.userId, FriendKey.following: userId};
  try {
    var res = FollowersModel.fromMap(await (handleResponse(await buildHttpResponse(isUnfollow ? APIEndPoint.unfollow : APIEndPoint.follow, request: req, method: HttpMethod.POST))));
    appStore.setLoading(false);
    return res.message.validate();
  } catch (e) {
    appStore.setLoading(false);
    throw errorSomethingWentWrong;
  }
}