I’m going through a weird behavior using the signInWithEmailAndPassword
method of firebase_auth
the try catch
block should catch if an error is thrown but a PLatformException
flows up in the editor like I did call a normal async/await method without catching errors :
the weird thing is that I already used the same code in a previous project and it’s working fine, I did the same configuration, and it’s working fine with correct auth data, just if there is an error it doesn’t catch it
my code :
Future handleLoginProcess(BuildContext context) async {
_handleInputsCases();
_startLoading();
try {
await FirebaseAuth.instance.signInWithEmailAndPassword(
email: "[email protected]", password: "SuperSecretPassword!");
} on FirebaseAuthException catch (e) {
print('Failed with error code: ${e.code}');
print(e.message);
}
_endLoading();
}
the thrown error seem to direct me to this:
if (errorCode is String && (errorMessage == null || errorMessage is String) && !buffer.hasRemaining) {
throw PlatformException(code: errorCode, message: errorMessage as String?, details: errorDetails, stacktrace: errorStacktrace);
} else {
throw const FormatException('Invalid envelope');
}
I’m missing something, what are the possible reasons to this, is it something related to vscode?
please share your ideas with me, thanks
3
Answers
If this code working well in your another project. then you should check SDK Version of both projects. You can find SDK version in YAML file.
Check your flutter implementation too.
In pubspec.yaml
Code
When i went through this error the only solution i found was to create a whole new project on Firebase, on Google console and on my computer.