What i am trying to do is i am fetching profile from fetchUser.But i don't know any other way that i can pull http data other than string.
class FollowingUserModel {
final String id;
final String author;
User profile;
final String profileid;
FollowingUserModel({this.id, this.profileid, this.author, this.profile}) { profile = fetchUser() as User; }
Future<User> fetchUser() async{
final response = await http.get("$SERVER_IP/api/users/$profileid/?format=json");
if (response.statusCode == 200) {
var responseJson = json.decode(response.body);
return User.fromJSON(responseJson);}}
factory FollowingUserModel.fromJSON(Map<String, dynamic> jsonMap) {
return FollowingUserModel(
id: jsonMap['id'] as String,
author: jsonMap['author'] as String,
profileid: jsonMap['profile'] as String,
);}}
Does anybody know how to do it?