Skip to main content

getComments method

Future getComments ()

<p>This methods fetch all comments on the post. The function uses <code>getCommentsForPost</code> method by Comment Service.</p>

Implementation

Future getComments() async \{
setState(ViewState.busy);
final List commentsJSON =
await _commentService.getCommentsForPost(_postID) as List;
print(commentsJSON);
commentsJSON.forEach((commentJson) \{
_commentlist.add(Comment.fromJson(commentJson as Map\<String, dynamic\>));
\});
setState(ViewState.idle);
\}