Firebase Auth Exception Handling | Email Password | Flutter Firebase | #firebase #flutter

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone and welcome back to this amazing flutter and Firebase series it's been a while since I uploaded the last video because I was caught up in some projects but now I'm excited to be back and creating content for you so in this video we are going to explore the exception and we'll come to know how we can handle the exception so before we start handling the exception let's quickly recap what we have done in the last episode episode in the last episode we write two methods for our user the sign up with email and password and also the sign in with email and password now let's check these two methods that they are currently working or not let me create a new user his name will be flutter email will be flutter accurate gmail.com password will be 1 to6 let's sign up that user and there we go our user is successfully created now let's log in that current user by email and password flutter gmail.com password and let's login and that's good they both work very well now if you remember in the last video we created to Boolean variable is signing up and assigning in the value of of these two variables are by default false and what we are going to do with these two variables we are going to show loading indicator on the place of that login and sign up text so that the user comes to know that we are in process and our user is signing to the application now to achieve this functionality we will go to the login page and in the signin method we will set the value of the assign assigning in variable to true and when the method calls it will first through the value of assigning variable and after that the whole process will come now after the user log into the application we will simply sit St the value of assigning variable to false now with the help of this assigning we will load the loading indicator on the place of this text for that we will do this is assigning when assigning is true we will show circular progress indicator and its color will be colors. white otherwise we will show the text so now same for the signup page in the sign up method we will sit State the value of that variable to false sorry to true and below this method we will make it false okay now same as we done in the login page just show the loading indicator here when assigning up equals to true we will show the circular progress indicator its color will be colors. white and otherwise we will show the login text now H reload the application and let's check that this functionality works or not now let me try to log in the same user we created before flutter gmail.com and his password will be 126 and let's try to login now when I press the login button it will show a loading indicator here and as you can see the loading indicators works very well and after some time our user signed to the application now let's create another user and check the functionality of this page developer developer X gmail.com the password will be 126 now let's sign up and there we go we got overloading indicator here now it's time to handle some exception in the Firebase o services in recent video we already did this on Firebase o exception but didn't handle the exception here make sure you write the Firebase o exception here so that the exceptions are coming from the Firebase and here we will check that the email duplication if the email is already in use we will simply show a toast with the help of this flutter toast package to the user that this email is currently in use so we will simply write the exception here here what are we doing is we are checking if the E is coming from this catch Firebase Au exception if the email is already in use we will show a toast message to the user that the email address is already in use if there were some network issues we will show the an error occurred code so now let's create this short host method we will create a directory in the lip directory which will be Global and inside that Global there will come another directory called common and this common folder will have a DOT file which will be a toast so this do file is having a method called the show toast where what is going on here is this flutter TOS is coming from the flutter TOS package and it will show the message which I pass the parameter here and the to length is length short gravity is bottom time in second for iOS web 1 background color is red text color is white but we will change the background color to blue because our application UI is blue and the font size is 16 now back to the Firebase off services and just alt plus enter which is the shortcut in Android Studio press it and import this Library okay now in the sign in with email and password we will just simply catch the exception that the email you writing is created or not we will simply show to the user that invalid email or password please check your email or password for that we will write this here we are checking that if user not found or e. code equal equal to wrong password if user write the wrong email or type the wrong password we will simply show the toes to the user that invalid email or password or if some network error occurs we will simply show the N error occurred so now how to reload the application and check this functionality in real time that these are working or not here we go our application is reloading and now let's me type a dummy email that does not exist in our database base D gmail.com when I press the login as you can see an error occurred unknown so the unknown is coming from this e do code and an error occurred is coming from this show toast which we write the message here now if you write the password Here 1 2 3 now if I press this login button it will show that invalid email or password so that's how it work now let's go to the sign up and let me write the exact same email that we created before flutter it sorry it will be a username and the email will be flutter gmail.com so it's the same email that we created before and the password will be Sam now when I press the sign up it will show that email is already in use as you can see here the email address is already in use so that's how we can handle some exception here in the Firebase service now it's time to handle some other things that needs to be correct login go to the login page and which are scroll a bit down here in the place of print user is successfully created when the user is not equal to null so it will print a statement user successfully created in the run time so we will just simply replace this print with show toast and it will accept the message and also replace this print statement with the show toast and pass the message and that's it now if the email and password is correct it will show to to the user on the display that user sucessfully created so when I try to sign up let's name it ASD sd23 gmail.com and the password will be 126 let's try to sign up a loading indicator and welcome home bud so it doesn't show the show toast because we have to post this show toast here in the sign up method we will just remove this for a while and hit enter show the toast here after the sign up method now how reload the application I think I didn't reload the application before that was not working so now it's time to reload the application and check that it's working or not I think I have to remove this short host but let's check it sign up ASF SF gmail.com password will be 1 to6 now let's sign up user is successfully created it's just because this we have to remove this one and let the other one stay and one other thing when the user sign to the application or created so when I press the sign out it will say the show toast user or successfully signed out import this show toast and contrl S let me click on the sign out button and as you can see successfully sign out and same for the login page scroll a bit down come to the method of login replace this print with show toast and it will accept the message users say successfully signed in in the else condition we will show toast message will be some error occurred and that's it how load the full application and let's check the full functionality of our app there we go let's create a new user and check the functionality step by step username will be let's say Mary Mary gmail.com password will be 1 2 3 4 5 6 and let's sign up and as you can see user is successfully created and it shows a toast now when I click on this sign up out it will say successfully sign out let's try to log in that current user Mary @gmail.com password will be 1 2 3 4 5 6 click login user successfully sign in click on the sign out and that's it that's how we can handle some type of exception in our code I know it's a little things but I will make another video on that exception when we go to the production type projects I hope you like the video if you found this video helpful please make sure to subscribe the channel like the video and comment if you have any problem and stay tuned for the next video because the next videos are very amazing and be ready for it so goodbye for now
Info
Channel: CodingxTalk
Views: 1,234
Rating: undefined out of 5
Keywords: flutter, firebase, flutterfire, firebase setup, flutterfirebase, firebase cli, dart, firebase series, firebase auth, exception handling, firebase exception, try catch, flutter firebase setup, firebase auth exception flutter, firebase error handling, bug fixing, codingxTalk, firebase push notification, email password, authentication, firestore, google authentication, facebook authentication, handling exception, firebase database, crud operation, cloud storage, flutter deep, analytics
Id: qcSkdwjpOdY
Channel Id: undefined
Length: 12min 20sec (740 seconds)
Published: Mon Oct 23 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.