getBugs method

Future<List<BugModelCustom>> getBugs()

Fetches all bugs created by the currently logged-in user from Firestore.

Returns a List<BugModelCustom> containing all matching bugs.

Filters by createdby field matching the current user's UID.

Implementation

/// Fetches all bugs created by the currently logged-in user from Firestore.
///
/// Returns a [List<BugModelCustom>] containing all matching bugs.
///
/// Filters by `createdby` field matching the current user's UID.

Future<List<BugModelCustom>> getBugs() async {
  final currentUser = FirebaseAuth.instance.currentUser;

  final snapshot =
      await bugcollection
          .where('createdby', isEqualTo: currentUser?.uid)
          .get();

  return snapshot.docs.map((doc) {
    final data = doc.data();
    return BugModelCustom.fromFirestore(data, doc.id);
  }).toList();
}