'how to print error message when the logging details are wrong

I want to print error message receiving from backend API, when the logging details are wrong. how can I do this using flutter

String userEmail = email;
String userPassword = password;
var Logindata;
Dio dio = new Dio();

Future LoginData() async {
  final String LoginDataURL =
      'https://hit.herokuapp.com/user/Login';
  dynamic Logindata = {
    'email': userEmail,
    'password': userPassword,
  };
  print(Logindata);
  var response = await dio.post(LoginDataURL,
      data: Logindata,
      options: Options(
          headers: {'Content-Type': 'application/json; charset=UTF-8'}));


  return response.data;
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source