submitButtonHandler method

Future<void> submitButtonHandler(
  1. String text
)

Updates the comment text to the new value and saves it to Firestore.

Implementation

Future<void> submitButtonHandler(String text) async {
  if (text.isEmpty) return;

  CommentModel comment = state.copyWith(comment: text);
  if (comment.isEdited) {
    comment = comment.copyWith(lastEdited: DateTime.now());
    ref.read(firestoreServiceProvider).editComment(commentSectionID, comment);
  } else {
    comment = comment.copyWith(commentDate: DateTime.now());
    ref
        .read(firestoreServiceProvider)
        .createComment(commentSectionID, comment);
  }
}