Когда я вызываю мой API отдыха, у меня появляется ошибка:
I/flutter (25698): {user: {firstName: Jérémy, lastName: Gachon, pseudo: jerem, email: exemple@gmail.com, password: Abcd1234, birthDateDay: 24, birthDateMonth: 12, birthDateYear: 2004, language: fr}}
I/flutter (25698): gg1
I/flutter (25698): type '_InternalLinkedHashMap<String, String>' is not a subtype of type 'String' in type cast
А вот и мой код:
Future<User> handleSignup(String email, String password, String pseudo,
String firstName, String lastName, String birthDate) async {
var finalBirthDate = birthDate.split("/");
Map userDataFormated = {
"user": {
"firstName": firstName,
"lastName": lastName,
"pseudo": pseudo,
"email": email,
"password": password,
"birthDateDay": finalBirthDate[0],
"birthDateMonth": finalBirthDate[1],
"birthDateYear": finalBirthDate[2],
"language": 'fr'
}
};
print(userDataFormated);
try {
print("gg1");
var res = await http.post(globals.apiUrl + "auth/createUser/", body: userDataFormated);
print("gg2");
print(res);
if (res.statusCode == 201) {
final map = convert.jsonDecode(res.body);
final User user = new User.fromMap(map);
return user;
} else {
print(res);
}
} catch (e) {
print(e);
}
}
Компилятор не принимает, когда я помещаю карту в пользователя в мою карту тела.
Спасибо заранее.