var res = {
"data":{
"errors": {
"email": [
"The email has already been taken."
],
"password": [
"The password must be at least 6 characters.",
"The password confirmation does not match."
]
}
}
};
res["data"]["errors"].forEach((key, messages) {
if ("email" == key) {
// show email errors like this
for (var message in messages) {
// Use your Flushbar here to show the error message
}
} else if ("password" == key) {
// show password erros like this
for (var message in messages) {
// Use your Flushbar here to show the error message
}
}
});
编辑
为了更短,您可以像这样将您的消息合并为一个
String combinedMessage = "";
res["data"]["errors"].forEach((key, messages) {
for (var message in messages) combinedMessage = combinedMessage + "- $message\n";
// Use your Flushbar here to show combinedMessage variable
});