You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Need to add list default value or nullable.
Json sample:
{
"userImage": "Shohrab",
"socialMediaInfoess": [
{
"ProfileID": 2,
"SocialMediaURL": "http://facebook.com"
}
]
}
Output sample:
class ProfileInfo {
final String userImage;
final List socialMediaInfoess;
ProfileInfo({
this.userImage = "",
required this.socialMediaInfoess, //remove required and add default value or nullable (if possible)
});
Need to add list default value or nullable.
Json sample:
{
"userImage": "Shohrab",
"socialMediaInfoess": [
{
"ProfileID": 2,
"SocialMediaURL": "http://facebook.com"
}
]
}
Output sample:
class ProfileInfo {
final String userImage;
final List socialMediaInfoess;
ProfileInfo({
this.userImage = "",
required this.socialMediaInfoess, //remove required and add default value or nullable (if possible)
});
factory ProfileInfo.fromJson(Map<String, dynamic>? json) => ProfileInfo(
userImage: asT(json, 'userImage'),
socialMediaInfoess: asT(json, 'socialMediaInfoess').map((e) => SocialMediaInfoessItem.fromJson(e)).toList(),
);
Map<String, dynamic> toJson() => {
'userImage': userImage,
'socialMediaInfoess': socialMediaInfoess.map((e) => e.toJson()).toList(),
};
ProfileInfo copyWith({
String? userImage,
List? socialMediaInfoess,
}) {
return ProfileInfo(
userImage: userImage ?? this.userImage,
socialMediaInfoess: socialMediaInfoess ?? this.socialMediaInfoess,
);
}
}
class SocialMediaInfoessItem {
final int profileID;
final String socialMediaURL;
SocialMediaInfoessItem({
this.profileID = 0,
this.socialMediaURL = "",
});
factory SocialMediaInfoessItem.fromJson(Map<String, dynamic>? json) => SocialMediaInfoessItem(
profileID: asT(json, 'ProfileID'),
socialMediaURL: asT(json, 'SocialMediaURL'),
);
Map<String, dynamic> toJson() => {
'ProfileID': profileID,
'SocialMediaURL': socialMediaURL,
};
SocialMediaInfoessItem copyWith({
int? profileID,
String? socialMediaURL,
}) {
return SocialMediaInfoessItem(
profileID: profileID ?? this.profileID,
socialMediaURL: socialMediaURL ?? this.socialMediaURL,
);
}
}
The text was updated successfully, but these errors were encountered: