It is common to write a named fromJson
factory constructor which accpets a Map<String, dyanmic>
as an argument which is the json data you will pass to it.
For the code you provided it would be like:
class Test{
String fullName;
Test({this.fullName});
factory Test.fromJson(Map<String, dynamic> json) {
return Test(
fullName: json['fullName'],
);
}
}
Map ob = {fullName: "someAnotherName", another:another};
var t = Test.fromJson(ob);
t.fullName;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…