login method

Future<void> login()

Implementation

Future<void> login() async {
  CommonUtil().checkConnection().then((value) {
    if (value) {
      _status = Status.loading;
      notifyListeners();
      APICall().loginApp().then((response) {
        log(' LOGIN_RESPONSE ::${response.body}');
        if (response.statusCode == 200) {
          _loginResponse = LoginResponse.fromJson(json.decode(response.body));
          _status = Status.successful;
          notifyListeners();
        } else {
          _status = Status.failed;
          notifyListeners();
        }
      }).catchError((error, stackTrace) {
        _status = Status.exception;
        log('ERROR_INITIALIZE_APP :::$error==$stackTrace');
        notifyListeners();
      });
    } else {
      _status = Status.noInternet;
      notifyListeners();
    }
  });
}