// ignore_for_file: unnecessary_null_comparison import 'package:teso/Classes/TesoUser.dart'; import 'Post.dart'; class ThirdPerson { TesoUser? user; List? posts = []; List? following = []; List? friends = []; String? relation; ThirdPerson({ this.user, this.posts, this.following, this.friends, this.relation, }); factory ThirdPerson.fromJSON(Map json) { var posts = json["posts"] as List; List adverts = posts.map((e) => Post.fromJSON(e)).toList(); return ThirdPerson( user: json["user"] != null ? TesoUser.fromJSON(json["user"]) : null, posts: adverts != null ? adverts : [], following: json["following"] as List?, friends: json["friends"] as List?, relation: json["relation"], ); } Map toJson() { final Map data = Map(); data['posts'] = this.posts; data['user'] = this.user; data['following'] = this.following; data['friends'] = this.friends; data['relation'] = this.relation; return data; } @override String toString() { return '{"posts": "$posts", "user": "$user","relation":"$relation","friends":"$friends","following":"$following"}'; } }