So, I have created one snackbar widget in different dart file and I'm calling it in different dart file with context and text message. but when I'm getting error at that time snackbar is not showing on screen.
This is Separate dart file that contains Snackbar widget:
import 'package:flutter/material.dart';
import 'package:app/globals.dart' as globals;
class ErrorAlert{
showAlert(context, message) {
return ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: globals.mainColor,
content: Text(message),
duration: const Duration(seconds: 5),
action: SnackBarAction(
label: 'Dismiss',
textColor: Colors.white,
onPressed: () {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
},
),
)
);
}
}
Here the Code from where I'm calling it (in catch part if condition):
signInWithEmailIdAndPassword(email,password, context) async {
try {
UserCredential result = await fireAuth.signInWithEmailAndPassword(email: email, password: password);
User user = result.user!;
// checkUser = user; //returns UserID
if(result != null) {
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => const HomeScreen()));
}
}
catch(signError) {
if(signError is PlatformException) {
if(signError.code == 'ERROR_WRONG_PASSWORD') {
ErrorAlert().showAlert(context, 'Wrong Password!');
} else if(signError.code == 'ERROR_INVALID_EMAIL') {
ErrorAlert().showAlert(context, 'Invalid Email ID!');
} else if(signError.code == 'ERROR_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL') {
ErrorAlert().showAlert(context, 'Account is already exists with different credentials!');
} else if(signError.code == 'ERROR_USER_NOT_FOUND') {
ErrorAlert().showAlert(context, 'User not found!');
}
print(signError);
}
}
// return checkUser;
}
This is the debug message that is showing in console:
E/RecaptchaCallWrapper(32567): Initial task failed for action RecaptchaAction(action=signInWithPassword)with exception - The email address is badly formatted.