I have this if condition where I am calling a method inside, when reaching that part of the code I get the NoSuchMethodError exception. The called method inside of the if condition works perfectly fine as I do get the OTP code.
if (isUserExists) {
await AmplifyInstance().signInUser(_phoneNumber).then((status) {
if (status['result']) {
//some code here
}
});
}
Called Method -
Future<dynamic> signInUser(userPhoneNumber) async {
print('SignIn User');
try {
await Amplify.Auth.signIn(
username: userPhoneNumber,
password: userPhoneNumber 'Bol',
);
statusMessage['result'] = true;
} on AuthException catch (e) {
statusMessage['result'] = false;
statusMessage['errorMessage'] = e.message;
}
}
Here the statusMessage returns true to the calling method.
Here is the snip of the error I get -
CodePudding user response:
signInUser
doesn't return a value. Also since you're using await
on line 166, you don't need then
and you could access statusMessage
variable on the next line.
If statusMessage
is not accessible in that scope, you could return statusMessage
from signInUser
.