unfollow method

  1. @override
Future<void> unfollow({
  1. required String followerId,
  2. required String targetId,
})
override

Removes the follow relationship from followerId to targetId.

Implementation

@override
Future<void> unfollow({
  required String followerId,
  required String targetId,
}) async {
  try {
    final batch =
        _firestore.batch()
          ..delete(_followersDoc(targetId, followerId))
          ..delete(_followingDoc(followerId, targetId))
          ..delete(_followsCollection().doc('${followerId}_$targetId'));
    await batch.commit();
  } catch (error) {
    throw Exception(
      'FirebaseFollowSource.unfollow failed '
      '($followerId → $targetId): $error',
    );
  }
}