getFollowers method

  1. @override
Future<List<String>> getFollowers(
  1. String userId, {
  2. int? limit,
})
override

Returns IDs of users following userId.

Implementation

@override
Future<List<String>> getFollowers(String userId, {int? limit}) async {
  try {
    var query = _followersCollection(
      userId,
    ).orderBy('createdAt', descending: true);
    if (limit != null) query = query.limit(limit);
    final snap = await query.get();
    return snap.docs.map((d) => d.id).toList(growable: false);
  } catch (error) {
    throw Exception(
      'FirebaseFollowSource.getFollowers failed for "$userId": $error',
    );
  }
}