 Hello guys. So in this video, we are going to see sign in sign up supply screen. I've already designed logout and homescreen. So I will be showing you the get request and post request over here. So I just restart and show you that flow of this application page. First of all, it will go to the supply screen. So this is just the design of the supply screen. And here you can see on the left side. And once after four seconds, it will be navigating to login page that you can see over here. So you can also go to sign up from here. Then come back to login. I just hit login. So for the time being, I just added a static code over here, like home page, login page, sign up page, flash. And this is a common widget I have designed so that I can reuse that text. So first of all, we need to add some dependencies. So let's go to pubpec.eml. And here we need to add dependencies. So just go here under dependencies and go to your browser and search for this HTTP dependency. This is required for ap equals. This is another one which is required to maintain the storage local storage so that we can maintain the state of login user. This time it would not ask for credentials. Let's go here, paste it and the same. We'll take some time to fetch the dependencies. Let's close it. And meanwhile it is fetching the dependencies. So I have these pages over here in this folder. The models I have not created any yet. And the repository folder is here. And this is a widgets folder. They have a place to commonly used widgets. So you can, I just doing the simple example, I will just add one new file here. Let's make it. Both the scope. So I'm just keeping my logic into this repository. If you want later on, you can add more layers like you can work with a service layer or if you want, you can convert it into any mbc or mbp, whatever kind of pattern you want. So let's create this authentication wrap class. And here we need some URLs from where we are going to call the APS. So for ap equal, I'm going to use this mock data that is fake apS. So here, first of all, we need, let's go with the login first. So do we have any login here we have this login. Go here. And you can see it is showing what you need to do. You need to send a request to this URL and then you have to pass this as a header. Let me just go here and use this URL over here. And I just keep it here. Let's say static. Let's say login user URL. Let me just write another register user URL and we need on screen. So we will show get users and anything else we need. So I think this is one is three URLs. We need the first one is done. Then for register user, let's go here and go for register. I mean, this one, I just copy this here for register. And for getting the list of users, let's go back here and list of users test. Let's use this one. Go here. You can just specify page one as well. Let's use this URL and go here and go to the list. Okay, so URLs are ready. Now what we need, we need one constructor. So let's do it. So here we have to use shared preferences as well so that we can maintain the state of the user that the user is logged in. Let's do it static. Late. We will initialize it later on shared. Preferences. Let's keep it perhaps. And here we can initialize that. So let's create another function. Let's say underscore shared preferences. And we just created over here underscore. And here what we are going to do, we are going to say that is equal to and we have to make it. Think and await. Let's use. And wait for. Here. So this gonna initialize your shared preferences. Now, next we need one. Next, let's do create some functions over here. Let's say the first one we are going to say register a user. So let's create a functional register user. And this register user. It takes some arguments. Let's make it a named arguments that we can identify easily. Required. Spring. Let me cross it first. So what it is expecting for logging. It is asking for. Just go here. It is asking for your email and possible two things we need. Okay, let's go back. We need email. And. This. Required. Then. Two things we need to take input. And once we got this, you have to just use, let's use try. Catch. For exception handling as well. Here we can say. Let's say. And here. Here we need to write. We need to make it a sink as well. Let's make it. And. So we need to use. So for that, we need to import this. I just show you. Just go here. Scroll down and you can either copy any of these one. Let's say I use this. So they have mentioned the example how you can use. Let's go back here. And. Import this. And now you can use. So for here, we have to do what. This for. Register user. So we have to use which request. Just go here and close. For register user. We have post request. Okay. So we have to call this method. Post. And here you need to specify the year. For register. We have this already created. You cannot. Pass it. Just use this. Dot. And here you can pass you. That is this. The second argument. You need to pass that would be the body. The body would be. Two things that there is. You can just go check it from here for register. We have to pass two things like this. Just go back here. And. And just. Stay straight over here and remove. This is extra. Let's cross check. So here we have to use email. And the email is coming from. Password. So that's it. And for registration. That is done. And we have to check for the response as well. So this is going to give us. Future of response time. Let's create one. Response type of variable. Use this. So it's a big response. And just cross check it. This response type of variable. Use this. Just cross check it. This response is taken from. To make sure this response is taken from this. To be respond. Okay. This. So this response very well. We need to cross check. How do you check. We will check if this response. Dot. Let us go. We're going to give you some integer value. That integer value we have to go. That is 200. If the status score is 200. That means. It is. It is okay. That means what. You can simply return something. You can say. You can say. Just. Whatever you want. You can just return it. And that's all over here. Otherwise. There must be some error. Otherwise. There must be some error. So then you can simply return. The. Error you will be getting like. Let me just cross check it. So. Error could be coming like this. So we can just go. Here. And simply say return. You can either return any type of. Response. Let's say this. Response. Body. Let's keep it simple. Then later on we can just. And we can retrieve the desired value. So if it is fine. Then success. Otherwise return something else that might be. Error. So if you exactly want to take this error. You have to convert this. Body part into. We just do it for you. But let's say. We can simply return this. Like. The station. The code. You can pass this. Like this. And from here. We have to get that. Like this. You can experiment it. Whatever kind of. Error you want to represent. So accordingly you can reformat. Okay. So with this we have done with this. Just a user. I just need one more function. That would be for. Login user. Let's. Right here. And same way we need. These two arguments over here. Here we need to change this. You are. No. And here again we need to process. And. Once it is done. Instead of returning success. What you can do. You can just. First of all complete this one. So here if you're attending something. You have to. Use your future. Okay. So we are turning a sort of string. So let's use. Of. Here. You have to return. Let's keep it simple. Of. And. We will do what we return. To. Turn. Otherwise. Simple. Now apart from doing this. We have to save this. Information. We have to save something into. So that each time it will not ask. For logging. What we can do. We can just go on the top. And here we're going to create one. That's a static. And. Let's make it. Most. So what we can do. We can just keep it a key. I just make this one is a key. So that each time I have to use. I will just use it. Instead of. Manually writing the name. We make a bit mistake. So I just create one. We will use it. So that's fine. And now go back over here. We need. To check here. Once this register is successful. Or logging is successful. We're going to get back what. I'm talking. So just go here. You can simply use this line. To retrieve your data. Right here. And this is. Paste it over. This is going to give you the token back. And that token. Let's keep it like this. I know. It's equal to this. This stop. You can save it into. How do you do so? Not. Boom. And the key we will be using. This one. That we have. We will not commit any mistake in talking. And the value. Is. Because it's successful. Okay. And once it is done, you can simply return. Through. This token you have to save. In share properties as well. So crap. Set. The key. Again, we have to specify here. The key. And we will make it. Although we will not be using this token. Let's. Define it. But whenever you work with our big projects, you have to keep your token. So that's why I'm just adding one more line over here. So that you can see how the token is being saved. So here. Let's go. And this would be. So what we can do. This token. That means. I just make it. User. So that. There's any problem understanding the things. So here we have to. Specify the name. Of this. That is the key of this token. That is the key of this token. So. That is the key of this token. That is token. Okay. The actual value coming from the response. And this is the name string. That is token. You can also make it. Use the token if you want. That is your choice. So make sure you use it from here whenever you will use. Otherwise you may have spelling mistake mismatch. So let's come back here. And once it is done. And fun. So this. Save this value. And. Let's create one more function over here. To know whether the user is already logged in. Or not. So that's going to give you. Future. Of. And we will check here. Is. Locked. In. Here we can check for. The. Value. Dot. That is. We have this variable over here. Is. Log. If user is logged in. That's used like this. If it is false. You can simply check like this. If. This is going to give you. This is going to give you what. Another level expression. So. What we can do is use this question mark over here. You can just check and give it a department. If. This will give you now this is going to give you. All. Okay. If. This get pool. Don't contain any value it will give you now. That means user is not logged. Okay. If it is. You can simply return. Okay. Whether the user is logged in or not. If it is yes. Then it should return true. That means the user is logged in. Otherwise. It should. Okay. I hope there is no. Problem in this. So this. Gonna check the value from logged in user. If the value is. Yes logged in. Then return true. Otherwise. scenario. If there is no value associated with this logged in variable. This is going to give you null. And this null check will give you default value false. So that means it will not work. And. Okay. So we will use it once we will. Just reopen the app again and again. And we left with something. Yes. So we are going to do some more function. That is future. Of. All type. That's going to do what about the. So here what we need to do. Once. User is logged out. What we need to do. We just need to do simple. That is await for this preference. Dot. Clear. Clear everything. The value. That shared preferences has been. Clear. That's fine. So this is. Done with a rapport. Now what we can do. Let's go. To this. Looking page. And we will try to use this. Over here. And this. Just go to here. And this is the static code. I have added so far. Okay. So first of all, let's go over here. On the top. And. They have given some different. I just do what. I can use these default values. So that I should not fill. Again and again every time. Or testing. Will save my time. The password. Is this. We'll try to change it. Okay. That's fine. Now what we need here. We need one more variable. That is. Antiquation repository. The creation. A rapport. That is. Both repo is equal to. Optication. Okay. So with this, we can just call some functions. Let's go here. And here. Here what we need to do. Here we need to check for that. Let me just remove. This. And simply we need to check for what. Both. Apple dot. Login user. And you have to pause this email and password over here. And since it is. Of. Future type. Of. And if we're using of it. Market sync. And. This part is. Because we are using it. Inside this. Async. And here you have to check. If this. Mounted. This navigation. Whenever you're using navigator. Inside the. Async context. So make sure this check for this monitor. It is mounted. You can simply do. So let's save this. And just restart the app. Okay. So we have to this. Stop this app. And just rerun it. Because we have added that. It proposes dependency. So. Let's check with this. For username and password and see. What we are getting. So we got this success. And we just. I know. And let me change this password to something else. And then. Let's try to log in again. Again it is working. So what we are doing here. Let's go here. On this. Logging page. We just go here and simply. Print here. Or. Let's say. We said done here. And check if everything works fine. David. Just go back here. And just specify any other. Name. And just log in. So you can see it is giving you invalid credentials. And try with something else. And log in. You can see it is saying invalid credentials. You can see it is saying invalid credentials. Okay. I'll just go ahead with correct username and password. We'll say. Okay. So let's remove this. This is how a people will work with a get. And same way. We just go for. Here for. If I log out. Nothing will happen. So if I. Log in. So suppose I'm logged in. I just close the app. And I just open the app again. And. You can see what it is doing. We'll simply go to log in. So I have already logged in. I don't want to log in again. So what should I do now? I just go to the supply screen. And here where I was. Spending four seconds of waiting time. I will check here. If. User. Is already. Logging. Simply we have to use here. Again. Othrap. Since we are creating one instance over here. We can't use this concept. And you have to remove that comes from here as well. This. Go here. And here. This. Is already having one method. What we did do. If this. Is. User logged in. So. We will check with this method since it is. In. Turning a future. Wait for this. And I missed. This. So if it is giving you. To. Navigate to this. Otherwise. Sorry. It should navigate to home page. If it is successful. Otherwise. We will go to. Okay. We should not go for login again. We should. And. If it is not logged in, then it should go to. Let's save this. First. And check it here. It is giving some suggestions. Simply. Using that. Make it. We are creating the instance over here. Okay. So I just run it again. So meanwhile it is. Running. We can do what we can just write the code. For that. On page. And we have added a button. I can follow. So. On the press. What we are doing. Again, we need to use that. Repo. Let me just. Go here. I'm. This. This. And. So since we have already logged in earlier. So it is. Already showing you. I just restart. Okay. So what we left. Let me just complete this one here. So here inside this button. Press. We are. Currently going to the login page. But here we want to go ahead with that. So let's create a variable. Final. Is. Logged. Equal to. Authentication. Okay. So you will not be getting that. What's up over here possible. Let's make testing. And we can just take it into. Let's. Over here. Just undo this. Got it from here. We need. Over here. Okay. So that we use it over here. Here we have to check for. Final. Is. Logged. Let's do this. Let's use it here. And market. The same. And we'll check here. So we have to log out. Let's log out. Whatever the response is coming. So here. Again, we have to check. Check. For if it is logo. That is success. Then you have to do what you have to navigate to. This. Logging. And since. We are working inside this. Async. So you have to use. And. That's all here. And we have removed. That. Cons over here. And go here. Just. Okay. Save this. Now, whenever I will log out. It will go back to this. Logging. Logging. And we'll go to this. Now, if I close this. I just need to. Run it. It will execute the already installed build. So let's wait for this. Okay. So now after the splash, it would check. User is already logged in. It will not ask. As you can see. I just. Close the app. And run it again. And it will not ask for long. Since I have already got. But if I log out. And it will ask for long. Now we left with this to the sign up part. Let's simply. Run this app. And we just go to sign up. And write our code. Okay. So let's go here. And for sign up. We have. Which is true. And here. We have to pass these two things. That's fine. So we will get the response back. That's fine. So what we need to pass again. We need to pass these two things. Otherwise. I need to type it again. Anything. So. Now apart from this. We need that. Over here. Okay. So with this. What I need to do. For that. Register. Here it is. This would be. This. Sign up. Sign up. For sign up. This button. This here. So here. After this. We have to use that. Let's say. This. Register user. Here I need to pass. Email and password. So we get the email. So we already have the controllers over here. So. So we have email controller and password control. Let's go back here. Email controller. The same way. Password. Controller. So once we pass this. This is going to give us what? On string back. That's right. This is equal to this. And we can check here. If. That result. Is equal to is equal to. Let me just check it. Success. That means. It is registered successful. Okay. And take it over. What it is saying. So this is going to give you. Future. So let's. For this. This is. Why we are putting it into that state. We should not. I just do what. This state. Over here. After that. We're going to check for this. This is. Success. Then we will say. The message. Otherwise. We're going to do what. We're going to set the message one. So. We already have this. We need to set the error. Okay. Already using some variables. See. Is there. To here. And else. Is. Is equal to. To. And the result. You can. Whatever. And once everything is done. Loading. Over here. And then. That's. All. Let's save this. I just. Started. Let's go to sign up. Check for something. Wrong. I just changed this. Something else. Let's try with that. Sign up. And it is saying not only defined users. Exceed. Registry. That means this is the error. We were. Getting here. And here is a post method. That's fine. And you can print the response. That's going to give you a better clarity. What does he be going to give us. Because we are using some. Make. I don't know what. Return. Let's check here. Let's go to sign up. And let's try to. Change the. And. Sign up. And you can see instance of response. Instead of response, we have to say response. That we can see that. Again. And. We are getting this. Okay. So whatever response we are getting. So I just. As. Okay. So in case. We are using the correct user name and password. And. You can see what it is. The. Successfully go ahead and. So we are getting it. So let's remove the sprint. And save this. And just go to that sign up page. And. We just go here. And we'll check for. This message. So it's color should be clean. If. It's not empty. Then we are just printing this message. And if it is there. Then. Otherwise it should be green. Did I miss something? I just. Sign up. And just sign up. You can see now it is working. We have seen how to use. Get. We have seen how to use post API code. And further. We have to go for this home page as well. So here what we were doing. We are just using any. Anything. Not yet. We are just displaying this. If you want, you can use this. Function over here. That. We have not created any function for this. You want, you can create it over here. And display the list of users. Inside that. So how do you do so? So what we can do here. Supposed to go here. And look for the response. This is a response. And we can just create a model out of this. So we have this quick. Type. I. Here we can just create a model. Of any language. Just go here. Paste it. And I just. Users. And change the language to that. And. I make all of this. Go ahead. And if you want to. Copy this code. And go back. And under the model. We can just. Just. Just paste it. Now. Let's go back here. And. Let's create one function. Of. Users. And this is going to give you what? Let me just. This. And we have to return here. We don't need anything. Just we need to use the URL. That is. Just. Get users. So. Go here. This. This. And we don't need any body. We are getting this 200. You don't need this. You can simply return. This. You can simply return. Here. And here we have to return that. And. This. This. This. Model. We need to do what we need to get. The model. You can see this one. Give you what it's going to give you. One model. Okay. Here you need to pass the string. The string would be your response. Okay. That's fine. Otherwise. If you want, we don't need to add any condition over here. Just going to throw the exception. Okay, so. Just. Skip this. We can do. We can simply return that empty. User model. You want. So I just created. The. And here. Find all these things. Let's give it. Zero. Zero. You can use another way as well. Going with this. And here we have empty. Yeah. And for sport. Is required. So we can just cross it. What is the sport over here? What. Is again taking. One empty. Let's. Support here. To pass this to things. That is. We don't have. We don't. So there are different ways to handle this. Response. I'm not. That's the handling it. Was this going to give us this kind of data. So for the time being, I'm handling it. Like this. And if you want to go through the other methods of handling the response error. And check out my other videos. So let's. What it is saying. So it made it a nut. Same thing. You have to do what we don't need to try catch over here. You want. We can just use it instead of using. We can simply say. We move this right. We move this. And on homepage. We have to use. This. We have to use. This. And here you have to use. That is taking this context. And index. That's going to give you. And. Need to pass. That is. How do you get item count. We have to create. Something over here. Let's create first of all. For this. And on press. What we are doing. We're doing dog out. And here. Once in it done. That. Get. All. So once you got all the users. You have to assign into. Somebody. Let's do what. This. Late. Let's. Write your statement. Like we have done over here. I just created empty. What. To. This. And. So. Once it is done. You can simply. It is doing what it is doing. Let's say. And this. Would be. Find a. Which. We. We need to do what. Uses. For. This. So. Initialization part. Once. This is done. This is going to call this data. Which is going to get up on the. So once you receive this data. And go here and simply. You. Get the length of. Just grossed the response. We are going here. Every. This is important. We are getting the data from this data. Let's say. The. And here. We have to. Let's. So. The item. One of the way. Next. How do you do. Implicit. Dot. Dot. And you can simply pass the. So. We need to remove. The. And here. What we are getting. But that can't be assigned. So. We have to do what. You have to let's say print. First name and last name. And we do what. Dot. Some space. Plus. Just. Last name. So it is. Suggesting us. Using interpolation. This. And simply. This. Extra. And let's use another. Is there. That is also taking. Text. And here we can simply use. The. And I think that's all. And whether if you want, you can decorate the details. For your. I just go there. Then. Is taking some time. What we are doing. We have to do some variable over here. Let's say. Uses. What we do here. Is. And here we are going to replace this. We'll check. This. Dot. Dot. That is. What we cannot do like this. I just do. What I go here. Is loaded. Once. I will just. And we need to create it. On top here. I will initially make it false. Just do what here. Check for. This. It is loaded and show this list. Otherwise. So. That's. David. And check. Are we getting any response. Let's do what we just go here. And simply. Here. We will go. Are we getting something back for. Just restart and proceed. It's called. You can see this data is. Loaded now. What is the issue we are facing. For. Once. We just. We just. Move. Dot. And. You can see it is now loaded. What is happening. Once the data is loaded. We can simply say. We were missing. Let's save this and remove. And statements. We are getting. This. So that is all. So that is all for this video. If you have any doubt do comment in the comment section. Otherwise like share and subscribe. Thank you.