Hello, in this video, I am going to show you how to implement a date picker. Simply click a button or you know something that triggers our date picker picker or pop up labels to select dates and they'll be day, month and year. And that will we can select so grateful, you know, maybe I'm along for example, or reminder that sort of stuff. Okay, so to do this outside of our widget Buster in front of the class, what we need to do is create the the actual select a method that was the future. No. Don't call this select date.
And this is going to have the build context and the context and farther away from the asynchronous up facing curly braces. Inside here. We're gonna have final date time. So that's the format to be picked. So this is your determind no one has actually been picking which one was picked. And we'll say equals away.
Show date picker on implement all these manually second. So when you semicolon here before the contract was gonna set this context as being passed in. Next we are going to say the initial date and initial date, I am going to set it to eight so they'll be out and we'll create a new variable costs. type of date, time and score day num plus date underscore date equals date time dot now and the initial date will be the variable. And now all we need to do for the first date This is the basically the earliest date that you can choose date time. For this you just put open brackets put the year so say 1972.
And people laugh at the you know it's good two restrictions on a 2100 you will need in front of here. Now what we need to do is handle session state is not equal nor is not equal to the current data has been set click data then no need to recreate it. We can say we're gonna print out the gate and we're gonna say.to string and then we're going to say set state. Inside of here. We're gonna say Equals Actually you know what do it after this and now we need to create a button you can you know create any sort of budget slider you know fairness could be anything that allows you to trigger some event off can be a simple credit child This is going to be an icon button and in here on the tray icon icon, feel free to check out the icon button and the button videos for more information.
All tiny dots are in for alarm. It's sort of like got like a clock icon to it style to it. And we're going to say we need we need the on pressed event. So this is empty and we are going to select data path in Chrome context. save that and let's see what we have seen that the button that we click it. We can select today.
So obviously we can go. And as Tom said, select this one click OK. I can see it printed every 20 1919 February 2020. And that's it. That's really all there is to the date picker. If you're not knowing more information about the time picker, feel free to check out my next video on that.
If you have any questions, feel free to shoot me a message. And as usual, I look forward to seeing you in the next video.