class User {
final String? name;
final int? age;
final Map? userAuuth;
User({this.name, this.age, this.userAuuth});
Map<String, dynamic> toMap() {
return {'name': name, 'age': age, 'userAuuth': userAuuth};
}
User.fromJson(Map<String, dynamic> json)
: name = json['name'],
age = json[22],
userAuuth = json['userAuuth'];
Map<String, dynamic> toJson() => {
'name': name,
'age': age,
'userAuuth': userAuuth,
};
}
class ModelTest {
Map<String, dynamic> a;
aa() {
var a = User().toMap();
userAuth();
}
}
I have a User value of 'name': 'aaa', 'age': 23, 'userAuuth': {'aa': 'bb"}. And, I am trying to insert this value to Map<String, dynamic> a inside the class ModelTest.
I've tried many things and I also read that toMap(){} function would do it. But, I could not figure how to apply this method to a here. How can I assign the Map type to a variable using model?