Skip to content

Commit

Permalink
fixed the login button not working
Browse files Browse the repository at this point in the history
in previous cases, the login button was not working properly. But, it has been fixed in this update.
  • Loading branch information
SMSourov committed Sep 23, 2023
1 parent 6ca9b87 commit 3c53077
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ void main() {
routes: {
"/login/": (context) => const LoginView(),
"/register/": (context) => const RegisterView(),
"/notes/": (context) => const NotesView(),
},
),
);
Expand Down
25 changes: 18 additions & 7 deletions lib/views/login_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class _LoginViewState extends State<LoginView> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Login"),
appBar: AppBar(
title: const Text("Login"),
),
body: Column(
children: [
Expand All @@ -57,12 +58,20 @@ class _LoginViewState extends State<LoginView> {
),
TextButton(
onPressed: () async {
try {
final email = _email.text;
final password = _password.text;
final userCredential = await FirebaseAuth.instance
.signInWithEmailAndPassword(email: email, password: password);
devtools.log(userCredential.toString());

try {
// final userCredential =
await FirebaseAuth.instance.signInWithEmailAndPassword(
email: email,
password: password,
);
// devtools.log(userCredential.toString());
Navigator.of(context).pushNamedAndRemoveUntil(
"/notes/",
(route) => false,
);
} on FirebaseAuthException catch (e) {
if (e.code == "user-not-found") {
devtools.log("The user was not found. That's all we know.");
Expand All @@ -82,8 +91,10 @@ class _LoginViewState extends State<LoginView> {
),
TextButton(
onPressed: () {
Navigator.of(context)
.pushNamedAndRemoveUntil("/register/", (route) => false);
Navigator.of(context).pushNamedAndRemoveUntil(
"/register/",
(route) => false,
);
},
child: const Text(" Not registered?\nCreate account now"))
],
Expand Down

0 comments on commit 3c53077

Please sign in to comment.