Skip to content
Advertisement

how to render laravel validation errors in flutter

world,

I am fairly new to flutter but I have been using laravel for some time now.

I want to know the best way to display laravel form validations response in a flutter form submission to laravel backend.

Advertisement

Answer

When you make an api request it returns a response status code and also a response body. You can get the validation errors from the response body.

For example

login() async{
var response = await http.post('/url',data);
if(response.statusCode == 422){
print(jsonDecode(response.body['errors'])) //print out validation errors 
}else{
//your code
}
}
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement