Post class
Constructors
-
Post({required DatabaseReference ref, required String id, required String title, required String content, required String uid, required DateTime createdAt, required int order, required List<
String> likes, required int noOfLikes, required List<String> urls, required int noOfComments, required bool deleted}) - Post.fromCategory(String category)
-
Create a Post from a category with empty values.
factory
- Post.fromJson(Map json, {required String id, required String category})
-
This is the factory constructor that takes a map and produces a Post
factory
- Post.fromSnapshot(DataSnapshot snapshot)
-
Take note of the category node. Check the snapshot ref parent
because in
post-all-summaries
, category is part of the field. Since this model is shared bypost-all-summary
andpost-summary
, we need to check if category is included in the snapshot.factory
Properties
- category → String
-
Get the category of the post
no setter
- commentsRef → DatabaseReference
-
Post's comments' database reference
no setter
- content ↔ String
-
getter/setter pair
- createdAt → DateTime
-
final
- deleted ↔ bool
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
final
-
likes
↔ List<
String> -
getter/setter pair
- noOfComments ↔ int
-
The number of comments
getter/setter pair
- noOfLikes ↔ int
-
getter/setter pair
- noOfLikesRef → DatabaseReference
-
Member variable reference
no setter
- order → int
-
final
- ref → DatabaseReference
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- title ↔ String
-
getter/setter pair
- uid → String
-
final
-
urls
↔ List<
String> -
getter/setter pair
- urlsRef → DatabaseReference
-
no setter
Methods
-
delete(
) → 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), {Widget? onLoading}) → dynamic -
reload(
) → Future< Post> - Reload the properties
-
toJson(
) → Map< String, dynamic> -
toString(
) → String -
A string representation of this object.
override
-
toSummary(
) → Map< String, dynamic> -
update(
{String? category, String? title, String? content, List< String> ? urls, int? order, bool? deleted, Map<String, dynamic> ? otherData}) → Future<Post> - Update post data in the database
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- postAllSummariesRef ↔ DatabaseReference
-
getter/setter pair
- postsRef → DatabaseReference
-
no setter
- postSummariesRef ↔ DatabaseReference
-
getter/setter pair
- rootRef ↔ DatabaseReference
-
getter/setter pair
Static Methods
-
categoryRef(
String category) → DatabaseReference -
create(
{required String title, required String content, required String category, List< String> ? urls}) → Future<Post?> - Create post data in the database
-
field(
{required String category, required String id, required String field}) → Future - Get the value of the field of a post
-
get(
{required String category, required String id}) → Future< Post?> - Get a post by id and category
-
latestSummary(
{required String category, int limit = 5}) → Future< List< Post> > - /post-summary 에서 가장 최근 글 몇개를 가져온다.
-
postRef(
String category, String id) → DatabaseReference - Returns the reference of a post
-
postSummaryRef(
String category, String id) → DatabaseReference - Returns the reference of a post summary