getSinglePost method

Future<PostModel?> getSinglePost(
  1. String id
)

Returns a stream of posts with the given id.

Implementation

Future<PostModel?> getSinglePost(String id) {
  return instance
      .collection('posts')
      .doc(id)
      .withConverter(
        fromFirestore: (snapshot, _) =>
            PostModel.fromJsonAndId(snapshot.data()!, snapshot.id),
        toFirestore: (_, __) => {},
      )
      .get()
      .then((doc) => doc.data());
}