publishPost method

Future<void> publishPost(
  1. String postId
)

Implementation

Future<void> publishPost(String postId) async {
  final doc = await _firestore.collection('posts').doc(postId).get();
  final post = PostModel.fromFirestore(doc);

  final published = post.copyWith(
    status: PostStatus.published,
    publishedAt: DateTime.now(),
  );

  await _firestore.collection('posts').doc(postId).update(
        published.toFirestoreUpdate(),
      );
}