Here is my Code
RoundedElevatedButton(
child: const Text("Sign in"),
onPress: () async {
try {
await FirebaseAuth.instance
.signInWithEmailAndPassword(email: email, password: password);
} catch (e) {
print(e.runtimeType);
}
});
I want To send the user to the homepage directly after login succeeds
>Solution :
Modify the onPress function as follows:
onPress: () async {
try {
final user = await FirebaseAuth.instance
.signInWithEmailAndPassword(email: email, password: password);
if(user!=null){
Navigator.of(context).pushNamed('/home'); //Navigate to home screen.
}
} catch (e) {
print(e.runtimeType);
}
}