TimelinePost.fromJson constructor

TimelinePost.fromJson(
  1. String id,
  2. Map<String, dynamic> json
)

Implementation

factory TimelinePost.fromJson(String id, Map<String, dynamic> json) =>
    TimelinePost(
      id: id,
      creatorId: json['creator_id'] as String,
      title: json['title'] as String,
      category: json['category'] as String?,
      imageUrl: json['image_url'] as String?,
      content: json['content'] as String,
      likes: json['likes'] as int,
      likedBy: (json['liked_by'] as List<dynamic>?)?.cast<String>() ?? [],
      reaction: json['reaction'] as int,
      reactions: (json['reactions'] as List<dynamic>?)
          ?.map(
            (e) => TimelinePostReaction.fromJson(
              (e as Map).keys.first,
              id,
              e.values.first as Map<String, dynamic>,
            ),
          )
          .toList(),
      createdAt: DateTime.parse(json['created_at'] as String),
      reactionEnabled: json['reaction_enabled'] as bool,
      data: json['data'] ?? {},
    );