class User { AccountInfo? accountInfo; User({ this.accountInfo, }); User.fromJson(Map json) { accountInfo = AccountInfo?.fromJson(json['accountInfo']); } } class AccountInfo { String? id; String? userName; String? avatarUrl; String? phoneNumber; AccountInfo({ this.id, this.userName, this.avatarUrl, this.phoneNumber, }); AccountInfo.fromJson(Map json) { id = json['id'].toString(); userName = json['userName']; avatarUrl = json['avatarUrl']; phoneNumber = json['phoneNumber']; } Map toJson() { final data = {}; data['id'] = id; data['userName'] = userName; data['avatarUrl'] = avatarUrl; data['phoneNumber'] = phoneNumber; return data; } AccountInfo.fromMap(Map map) { id = map['id']; userName = map['userName']; avatarUrl = map['avatarUrl']; phoneNumber = map['phoneNumber']; } Map toMap() { Map map = { 'id': id, 'userName': userName, 'avatarUrl': avatarUrl, 'phoneNumber': phoneNumber, }; return map; } }