class UserModel {
String? token;
bool? success ;
UserModel({this.token , this.success});
UserModel.fromJson(Map<String, dynamic> json) {
token = json['authtoken'];
success = json['success'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['token'] = this.token;
data['success'] = this.success;
return data;
}
}
is fromJson allready defined (is it a inbuilt funciton? ) , is it a static funciton because we only call static function like Classname.staticfunction , why can it be writen like :-
fromJson(Map<String, dynamic> json) {
this.token = json['authtoken'];
this.success = json['success'];
}
Top comments (1)
I'm not sure what you want to achieve here but this works for me on DartPad: