Map<String, dynamic> data = {
"name":"길동",
"age":10
};
void main() {
print(data["name"]);
print(data["age"]);
}
class Person {
String name;
int age;
Person({required this.name, required this.age});
Person.fromMap(Map<String, dynamic> data) :
name = data["name"],
age = data["age"];
Map<String, dynamic> toMap() => {
"name" : name,
"age" : age
};
}
void main() {
Person p = Person(name: "길동", age: 10);
var t1 = p.toMap();
print(t1);
var t2 = Person.fromMap(t1);
print(t2.name);
print(t2.age);
}