I am using the plugin, which is great by the way, but i can't get the status code or the error message from the api callbacks?
Would like to implement some visual feedback to users depending on the error message or status code..
WPUserLoginResponse wpUserLoginResponse = await WPJsonAPI.instance.api(
(request) {
return request.wpLogin(
username: username,
password: password,
authType: WPAuthType.WpUsername);
},
);
if (wpUserLoginResponse != null) {
userTokenId = wpUserLoginResponse.data.userToken;
print(wpUserLoginResponse.message); // not working??
getUser(userTokenId, context);
} else {
print("invalid login details");
print(wpUserLoginResponse.message); // not working??
errorMessage = "invalid login details";
loginState = LoginState.signedout;
notifyListeners();
}
E/flutter ( 9788): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The getter 'message' was called on null.
E/flutter ( 9788): Receiver: null
E/flutter ( 9788): Tried calling: message
E/flutter ( 9788): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
E/flutter ( 9788): #1 Wordpress.login
package:mindmover/providers/wordpress.dart:45
E/flutter ( 9788): <asynchronous suspension>
E/flutter ( 9788): #2 _LoginPageState.build.<anonymous closure>