login method

Future<Map<String, dynamic>> login(
  1. String username,
  2. String password
)

Implementation

Future<Map<String, dynamic>> login(String username, String password) async {
  final response = await post(
      "/user/auth", {"username": username, "password": password},
      contentType: 'application/json');
  print(response.body);
  print(response.statusCode);
  if (response.statusCode != 200 && response.statusCode != 401) {
    errorDialog('Warning', 'System error please contact to Antodis.',
        Colors.orangeAccent);
    try {
      return response.body;
    } catch (e) {
      return {"error": "system", "error_code": response.statusCode};
    }
  }
  return response.body;
}