So now we have to register the new suit that is to serve the driver information to the Firebase Realtime
database.
So for that purpose, on our sign of screen here below this platform, let's create a new method by
the name serve driver info several driver info.
Now.
And first of all, in the very dirt form where we say short, I look, OK, got the score from here
and we will festered inside yourself, try in for now, just like this.
And in the elster moment, make sure to call the function which yourself driver in for.
No, OK.
Just like this.
So if everything is correct, OK, if all the conditions are satisfied, I mean, if the name is greater
than three characters, if the email is proper and if the password is not, if the phone number is also
provided and if the password is greater than six or six, then L's condition.
I mean, in that case, OK, when this condition has been checked successfully, OK, and everything
is preloaded in the form, then the start menu will execute and we will serve the driver info to the
Firebase Realtime database.
So let's just do that, OK?
After the short dialogue, we can say final user, which belongs to the Firebase or Dart Dart.
Can give it to name as far away as user equals two.
First of all, this parenthesis and then add a semicolon, OK, and then inside this parenthesis we
can say make this driver informed method is asynchronous.
And here we can say that let's create a new folder, new directory, and we will give it name as global.
OK, and then right click on a global new dark file and we will give it name as global server global.
Our dark side, which is inside the global folder, has been created and here we are going to create
a variable by the name
Firebase.
OK.
And let's give your name as f underscore Firebase what you to Firebase ought not.
Why are we so instance?
OK.
Yes, like this and then now on the sign up screen here, we can say underscore.
If it do not show, give us I mean, a suggestion.
It simply means that this is private, OK, here if you come here to the global order than we had here,
this underscore and this underscore basically make this fire miss ot.
Probably we are talking and private simply means that we do not accept it.
We cannot access it from any other file.
OK, so just remove the underscore from it, OK?
And instead of calling it far worse, what?
Let's give it an effort, which simply means Fire Resort, not OK.
And now they're just right here at fault.
First of all, let's break this in pieces, OK, so that we can see the court easily, OK?
Just press enter.
And then in here we can simply say it worked.
I fought, not quiet user with email and password, OK?
And it basically required two to the email and password.
We have to pass through it so we can pass it one by one.
First of all, the first parameter is the email and which we have here inside the email text wording
controller, so we can say email, text, wording, controller or text or claim comma.
Then we have password.
You can set password text rating controller, not text talk trim.
Now you will be thinking what this time means.
OK.
Let me just show it to you.
First of all, here, when you type something, for example, phone number, OK, and then you press
extra space, OK, you give extra space at the end like, say, in case of password.
OK, if you give it extra space, then it will also count the extra space if we do not give this stream.
OK, if you do not write their.
So for example, if your password is one two three four five six and then by mistake, let's say you
press this button, then it will also go in that space while you will remember that my password is from
one to six.
But it will also count the space that is best will also become a part of the password.
So then later on, you will try to log in by giving password from one to six and your password will
be not from one to six.
But it will have an extra space.
Also, OK when you press past and it also count OK.
Space has also its own ASCII value.
Same goes for the email, OK?
It will return an error message from the Firebase authentication as a result if you give extra space
here.
So that's why, OK, we do not want to include the extra spaces, so we used to trim alongside with
it.
So I hope you understand this now and then.
After it cleared user with the email password, it just required email and password.
And basically, this piece of code will create a new user in the Firebase authentication that is in
here, OK, in the authentication, it will create a brand new user.
OK, after that.
After that, of course, we want to save that user information in the realtime database as well.
So first of all, I mean, if as you would successfully in that case, OK, a new user will be created.
Otherwise, otherwise, there is also a chance that any error can occur.
So you can simply say it or catch error OK after the ending, but in solve to user with email and password.
And then here we can say MSG.
That is the error message, which it will give us as a return.
So in here we can see, first of all, make sure to add before this semicolon, OK?
You can dart user.
OK, just like this and then guess if any.
First of all, we want to make our progress dialog disappear so we can send the a out of context.
Also, make sure to add here this OK, no level.
And then you will, of course, display the floral toast.
I mean, that error message we have to glass of flutter to start your text and we can see error.
And what is the error?
The concatenation sign.
Plus we will say I miss G Dot to string.
So let me tell you one more time, OK?
This piece of code will basically, if this is executed successfully, a brand new user will be created
in the Firebase authentication.
OK, you will see it here.
Once we test, yep.
And then in case, if any are recurrent, then it will simply get that message error message as a result.
And.
You are displaying your 10, your message to the driver after it.
We want to save the driver information to the realtime database, OK, for later usage.
So for that purpose after this, we can say if the Firebase user ID is not equal to null.
If this not equals trouble, it simply means that if a user has been created successfully in the Firebase
authentication, OK, and so it will not be OK if it is not, it simply means the user is not.
The user has not been created successfully.
So first of all, let's implement that else condition, OK?
That is if the Firebase user is not there and if the user, which simply means the user has not been
cleared in that case, we will also display.
I mean, we will first disappear our dialogue, our progress dialogue and then using the flutter toast,
we will display a message that is.
Account has not been created after this, first of all, restart the book, and now they're just implement
and serve the data to the real time database.
So we will create a map for saying the data as it is to travel so you can say drivers map.
For saving the idea of their trailer, you can see Forbis
user.
You already coma.
And then please use the same key names, OK?
OK, I.D., for example, for saying the I.D. it is I.D. and name and the name is basically in how we
can get it from our name that certain controller or next door trim.
And then after it, we have email and phone, so now our this driver map contained this all information,
so we have to serve this driver map in our Firebase Realtime database.
So in here we can simply say no, we will create a separate parent node by the name.
First of all, let's create a reference to a database so you can say Firebase Database instance or reference
Dot Child.
So we will have Pattern Norb by the name drivers and inside the spent node drivers.
We will serve all the drivers information, OK with the help of each driver unique user ID.
OK, so how we can do it, you can say here driver and accurate name as first of all, create a database
reference object by the name drivers.
Ref means driver reference.
OK?
And then we can say drivers reference dot child.
And we will pass the idea of their specific driver who is going to register for the first time.
OK, and that is a new driver and their driver has their own unique user I.D. You will be with the help
of which we can recognize that specific driver.
And then we can see court set.
And here we have to bus our drivers map.
Basically, drivers map contain our whole information.
OK, so inside the driver's parent, not in the real time database, we will serve that unique I mean,
their driver, who is trying to register as a new driver.
OK.
And we are going to share the information with the help of that unique user I.D. for that specific driver
for each.
What I mean each driver will have their own unique I.D. after this.
We want to come here to the global dart.
And here we need to create an instance of, OK, this one phone was or not an instance of user, and
we will give it name as current Firebase user.
OK.
Just like this.
And then here on our sign up screen, we will sign the.
You will assign our fire to miss user to the current Firebase user, just like this.
And then after it, we will send the driver to the car in full screen.
So for that purpose, we will simply add here and they will not push and send the driver to the car
in full screen.
And also, if you want, you can display a flood of lost message and it will be basically to tell the
driver that his account has been created.
OK, now the next step is basically to save the car info to the database.
So let's just quickly go to the car in full screen as well and here on the car info screen.
The of knowbut, which is here, OK, remove the Navy air to not push, we do not need that here on
the court, in full screen, on the own breast.
Basically, we will call a function or implement that here quickly on both you which are built.
Serve God and for his own method.
And here, first of all, we have to define a map just like we did here for saving the driver personal
information, OK?
So just copy this whole map from here and on the car info screen.
You can pass it here, OK?
And we can see it.
Instead of driver map.
We can see driver card info, card information, driver card info map.
And here we have to basically serve the car color.
Then, of course, the car number.
And then we have the car model and then we type matches which type of car wrecks Superbowl or which
one and the will use of this, as you know, it is saving the car color, text, sterling controller
or text portraying.
And then for the car number, it is car no tax starting controller or text or trim.
And then, of course, the car model.
Kamal, or texturing controller or text true.
And the value for the type car type it is, if you remember, we have assigned to our selected car type.
So now we have to submit to the database on the sign up screen, the same reference which we created
here.
OK, just for the drivers to just copy it from here and on the car info screen after the amount we can
pestered and hand, first of all, important information about our daughter and the driver's collection
inside that we have that specific driver.
Are you going to say current Firebase user thought you already?
Make sure to check here.
OK.
And then, of course, the map we have to pass.
Driver Card Info Map now for saving the car info.
We will create a mean child within the dirt of that specific driver.
OK, that is.
It will how you can say this will be a subject and I will show to you guys when we test you so you can
see why the name car underscored details.
This will be a subscale car score details.
OK, for that specific driver who is not going to who has already registered.
I mean, personal information has been served.
And now the car details.
You also served here.
Know before before we go over this function, we serve car info.
Of course, we have to earn our validation.
OK?
And then we can call this car info method.
So for that purpose, the button, which is by the name now.
This one here, first of all, we have to check that is if.
So we can check first the car car color, texture controller or text.
No, it is not empty.
If this is not empty and if the car no tax reading controller or text talk is not empty, if this is
also not empty and then the car model tax-writing controller, not text dot is not empty.
This is also not empty.
They're just practicing pieces so that we can see it easily.
OK.
And then, of course, the last one, which is basically this electric car type.
So the selected car type?
Let me just check this.
I mean, how we define it.
Selected car type.
OK, so we can say that no, it is.
If the selected car type, if this not equals to null, OK, if this is not equal to none, that is
if it has some value only then.
Then.
We can separate.
We can call our function, which is car info.
Just like this so simple and so easy.
And then, of course, we can add a flatter toast just to let you try it with no.
Tossed out shortlist.
And you can see card details has been served.
Congratulations.
So, yeah, this is all about on this whole registration process.
So, no.
In full screen, and then, of course, after the successful this, we have to do something which is
to in full screen after a successful car details.
I mean, you read it yourself.
You are going to send the driver to the pitch, which is called split screen.
And I will tell you why we are doing this.
OK, MySpace screen because of my split screen, you will air the condition now.
So yes.
Now let me just restart the app.
I will go to the of this, okay, first of all, so that we can check it at real time.
So I'm going to create a user by the name Alex.
Hmm.
Molly is the user.
Then the e-mail, of course.
And then before name phone number.
And then, of course, the password.
I don't know that certain alert just click on Create Account.
Processing, please, that account has been created, we are on the court in full screen.
Now we have to if you click, come here to the fire vessel configuration, OK, and click on this reload
button here you can see your configuration has been created and if you go to the realtime database.
So here you can see the parents, no drivers has been created, and it contains our first trailer using
their unique ID if you notice this or six.
You should come here to the authentication and here you can see eight or six me and.
Six B and which is the idea for our first child who has just registered earlier direct mail, dot com
and fawn.
OK, and you can see the values of it here.
So how this code executed, just like I told you guys, OK?
Sign up screen shall see here.
First of all, as I told you, first of all, it prepared.
If everything was successful, OK, then it appeared a user in the Firebase authentication that is with
email and password.
OK?
And it also gave us this You are ready for this?
Try.
What do you mean?
And then when it goes well, then we check that if the user has been cleared successfully, then serve
this information using the paranoid reference for all the drivers.
OK, inside that parent, more drivers using that unique ID for that specific driver and save the map
that is driving a map that is a driver data in here.
OK.
In the realtime database, I hope you understand this.
OK, this is so simple and so easy.
OK, inside the driver's pen and not the first driver using the driver unique I.D. We saved their driver.
That is the driver information.
And then the next thing is basically it here, OK?
Then we go to the car in full screen here, OK?
So here we just fill up the form.
Let's say the car model is Tesla Model S and the car number.
Let's see, is this and then the car color alert says Black.
And then, of course, we have to choose the car type.
We'll call anyone you can choose and then click on Save No and no car details has been self-congratulation
and go to this screen.
And now if I come here and here, you can see inside that specific driver nord, OK, for that specific
driver whose name is Mohammad Ali.
And inside it, we have a man, a sub collection, a sub collection has been collected, which is created,
which is why the name car underscore details.
OK, so here we're going to see car color, car model, car number and type.
So that is what we say here.
That is, we created a map.
OK, you data which is on the car digital screen.
And then we create a reference to the drivers, which is the parent not for saving all the driver information
and that driver I.D. We pass here and inside that it has a sub child.
Or you can see a sculptural pattern not by the name car details, which contain all driver.
I mean, the driver car info, all car info for that specific driver car.
OK, car duty.
As a sub parent child, you can say OK in here for that specific driver.
So it is a subtitle which contains all the information related to the car details.