 Hey everybody, it's Brian. Welcome to the 40th Fledger Tutorial. Today we're going to be going over the simple dialog, which don't let the name fool you, it's anything but simple. It's actually a very powerful and complex piece of code here. So we're going to go over this in detail. First thing we're going to do is bring up our live template. If you have no idea what I just did, go watch video 35 in this series. Alright, so import and we're going to work with asyncs. We need the Dart async. And in here we're going to modify our state. So we want string and boy I cannot spell answer. That's embarrassing. Alright, so we've got our answer. Now we're going to function that sets this. We're going to say void set answer string value. And from here we're just going to do the set state. And from here we're going to say answer. Alright, so I just put that little to do there. So if you're using this is template you would say okay we're recorded to a file or send it to a database or whatever you were working on. So we have our little set answer there. Now we need to actually show the dialog. And this is kind of the meat of the tutorial here. No, not numb. Geez, what do you think in there? I'm going to do ask user. This is an async call. So in here what we need to do is build a simple switch statement. I'm going to say switch. And in here we're going to say case. I almost forgot what we need to do is back up just a bit. Part of what the simple dialog does is it actually can take in a numb and display it to the user and get the answer back to them or get the answer back from them. So we've got our a numb here answer. So we're going to say answer not yes. And then break and via the, let's just do this, set answer to the magic of copy and paste. We are just going to make a few of these here. Alright, and you could actually process it down here in the switch as most people do but they're all just going to call set answer because they're all pretty much going to do the same thing here. Alright, now that we've got our switch, we need to, well, switch. We need a value to switch on. So what we're going to do is await the show dialog and it has a build context and a child. And we're going to actually pop that over there so we can see very clearly what's going on. So the context is just going to be the current context and the child. We're going to show a new simple dialog. And the simple dialog has got a few properties. And what we're going to do is we're going to say the title and children. So title, do you like Flutter? And for the children, see that's an array of widgets so we can add literally anything we want to this. We could say like, you know, raised button or we could say text or, you know, radio or whatever we want. But there is a widget specifically for this thing and it's a new simple dialog option. Let's get the simple dialog option in there. And the simple dialog option has an on pressed, which we're just going to say null for now, and a child property. And the child, we're just going to say add a couple little, you know, things in there. And for the on pressed, let's do navigator.pop. And it takes the context and it takes a dynamic result. So the dynamic result is going to be answers.yes. So really what we're doing is when this is pressed, we're going to pop the navigator under the current context with that and on value right there. And we just grab this little guy. And I'm sure there is a much more streamlined way of doing this, but I want it to be very obvious what this program is doing. Expected to find, oh, they're completely forgot. So much for copy and paste saving is time. And then we have our maybe. We have the skeptical maybe in there. So just to kind of recap here, this function returns future null, which means we're actually not returning anything. It's an asynchronous function. It's asynchronous because the show dialog is extinct. We have to await on that. Switch on the value returned out of that. And what this does is it takes a numb, which we have up here and basically says, hey, which one of these do you want? So you have simple dialogue option that has the numb values in it and you are popping the navigator, meaning pushing that data back. I shouldn't say pushing, you're popping the data back. That's the correct way of saying it. All right. Now what we need to do is just simply say, hmm, there's our answer. I'm going to say new raise button. I'm just going to say, click me. And then, of course, we are just going to say bang bang and ask the user. Now this should work. Let's bring this up in our emulator. It seems to be taking a long time to compile these days. I really didn't do anything super complex. I wonder if it's my computer. There we go. So we have a you answered blank. And if we say, click me, do you like Flutter? Yes, no, maybe. And we're going to say yes because we love Flutter. And it says answered yes. So you can see how you can pretty much do anything you want here. Now the really neat thing about this is you can add other things because it is a, where is it? A ray of widgets here. You're not just constrained to the simple dialogue option. You can say something like, no idea what to put there, just icons not home or something like that. Hot reload should take care of that. And then we have a home icon at the bottom here. You can put buttons, icons, whatever you want. It's actually very, very convenient. So if you wanted to do like a radio list group, you know, so you have radios to check from or check boxes or, you know, do you like Flutter maybe and then like a little input field or something like that. You can do all of that. It's very, very straightforward. So that's it for this tutorial. I'm going to click yes because I like Flutter. Thank you for watching. You can find the source code for this and all of the tutorials out on my website void realms.com. And be sure to join the void realms Facebook group. I can't push that enough. Everybody sends me emails and questions. Join the void realms Facebook Facebook group. Ask questions out there. There's 1700 other programmers because I'm not always available. That's it. Thanks for watching.