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 } }