Comment class

Constructors

Comment({required DatabaseReference ref, required String id, required String? parentId, required String content, required String uid, required int createdAt, required List<String> urls, int depth = 0, List<String> likes = const [], String category = '', bool deleted = false})
Comment.fromJson(Map map, String id, {required String postId})
factory
Comment.fromParent(Comment parent)
Create a Comment from a parent comment with empty values.
factory
Comment.fromPost(Post post)
Create a Comment from a post with empty values.
factory

Properties

category String
Category is added here since we cannot access post category using ref..parent..key
getter/setter pair
content String
getter/setter pair
createdAt int
final
deleted bool
getter/setter pair
depth int
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
id String
final
leftMargin double
no setter
likes List<String>
getter/setter pair
likesRef → DatabaseReference
Membrer Variable Reference
no setter
parentId String?
final
postId String
Get the post id of the comment.
no setter
ref → DatabaseReference
Member Variables
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
uid String
final
urls List<String>
getter/setter pair
urlsRef → DatabaseReference
no setter

Methods

create({required String content, required String category, Comment? parent, List<String>? urls}) Future
Create a comment
delete({required BuildContext context, bool ask = true}) Future<void>
Delete post
like({required BuildContext context}) Future<void>
Like or unlike
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onFieldChange(String field, Widget builder(dynamic), {dynamic initialData, Widget? onLoading}) → dynamic
toJson() Map<String, dynamic>
toString() String
A string representation of this object.
override
update({required String content, List<String>? urls, bool? deleted}) Future

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

commentsRef ↔ DatabaseReference
getter/setter pair
nodeName String
Paths and Refs
getter/setter pair
root ↔ DatabaseReference
getter/setter pair

Static Methods

comment(String postId, String commentId) String
commentRef(String postId, String commentId) → DatabaseReference
comments(String postId) String
get({required String postId, required String commentId}) Future<Comment>
Get a comment from the database
getAll({required String postId}) Future<List<Comment>>
Get all the comments of a post
postComments(String postId) → DatabaseReference
sortComments(List<Comment> comments) List<Comment>
Get the comments of the post