getLastSeen method
Returns a stream of the last seen timestamp for a user.
Implementation
Stream<Timestamp?> getLastSeen(String userId) {
// Retrieve the updated document to get the lastSeen timestamp
Stream<DocumentSnapshot<Map<String, dynamic>>> userDoc =
_firestore.collection('users').doc(userId).snapshots();
return userDoc.map((snapshot) {
if (snapshot.exists) {
return snapshot.data()!['lastSeen'] as Timestamp;
}
return null;
});
}