All language subtitles for 3. Scaffolding a Flutter App

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French Download
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 0 1 00:00:00,410 --> 00:00:00,740 All right. 1 2 00:00:00,780 --> 00:00:08,160 Now in the last lesson, we created a brand new Material App, which is going to be the basis for all the 2 3 00:00:08,160 --> 00:00:13,760 other widgets that we're going to construct on-screen. And by including the Material App, 3 4 00:00:13,770 --> 00:00:20,070 we also get to tap into all of the components or widgets that the Material apps come with, such as a 4 5 00:00:20,070 --> 00:00:21,530 text or an image widget. 5 6 00:00:21,990 --> 00:00:28,260 But in this lesson, we're going to look at creating a scaffold in this Material app, so that we can have 6 7 00:00:28,350 --> 00:00:34,050 an app bar, we can have a body where most of our app is going to go, or we can have a floating button if 7 8 00:00:34,050 --> 00:00:35,340 we wanted to. 8 9 00:00:35,580 --> 00:00:43,090 And the scaffold widget is pretty much exactly that. You can use it to place common items onto your screen. 9 10 00:00:43,110 --> 00:00:49,290 I recommend reading the scaffold class documentation and seeing what it allows you to do. 10 11 00:00:49,500 --> 00:00:56,040 So inside our app, instead of having a centered piece of text, we're going to go ahead and delete all 11 12 00:00:56,040 --> 00:00:56,580 of that. 12 13 00:00:56,760 --> 00:01:04,350 So select everything up to the closing comment for the center widget, and you can go ahead and delete 13 14 00:01:04,350 --> 00:01:05,210 that. 14 15 00:01:05,220 --> 00:01:11,100 Now notice that these comments get created automatically, and it shows you for example, 15 16 00:01:11,100 --> 00:01:12,930 this is the end of the center widget. 16 17 00:01:12,930 --> 00:01:15,090 This is the end of the Material app widget. 17 18 00:01:15,480 --> 00:01:22,320 And if I added a comma here, and hit save, it separates out the text widget and shows me that this is 18 19 00:01:22,620 --> 00:01:28,410 the final closing brace. And this makes it easy for us to be able to, for example, take this part out, which 19 20 00:01:28,410 --> 00:01:33,630 is the text widget, or take this part out, which is the center widget just to be able to see where that's 20 21 00:01:33,630 --> 00:01:35,280 coming from. 21 22 00:01:35,280 --> 00:01:41,940 Now if it bothers you having a lot of this extra stuff that gets written on the screen, making your code 22 23 00:01:42,030 --> 00:01:50,070 look more wordy, you can also go into the preferences and going to the editor section, then general, then 23 24 00:01:50,130 --> 00:01:55,380 appearance, and you can either enable or disable this if you want. 24 25 00:01:55,380 --> 00:01:56,340 I'm going to leave it in. 25 26 00:01:56,340 --> 00:01:59,790 Just to make it easier for you to see where each part ends. 26 27 00:01:59,880 --> 00:02:02,940 But it's again up to you as a personal preference. 27 28 00:02:03,810 --> 00:02:07,830 So we were going to go and delete the center widget from here. 28 29 00:02:08,160 --> 00:02:14,430 So we're going to leave the part where it says home, but we're going to delete the center widget which we set as 29 30 00:02:14,430 --> 00:02:16,140 the home of our Material app. 30 31 00:02:16,740 --> 00:02:21,480 Well, it's going to be a scaffold widget. And a scaffold widget, 31 32 00:02:21,510 --> 00:02:27,420 you can see, can have a lot of different properties or different things that you can set. 32 33 00:02:27,420 --> 00:02:34,290 And that includes adding in a floating action button or changing what's inside the body of the app, adding 33 34 00:02:34,290 --> 00:02:39,560 in an app bar and a whole bunch of other things that you can do. In our case, 34 35 00:02:39,720 --> 00:02:44,890 we're going to firstly, add a comma at the end of every new parentheses we create. 35 36 00:02:45,090 --> 00:02:52,380 And inside the parentheses for our scaffold, we're going to add an app bar, by writing the words appBar. 36 37 00:02:52,560 --> 00:02:58,170 We're setting one of the properties of our scaffold. We're telling it that in the position where it expects 37 38 00:02:58,170 --> 00:02:59,280 to have an AppBar, 38 39 00:02:59,490 --> 00:03:02,810 we're going to put an AppBar widget there. 39 40 00:03:03,060 --> 00:03:11,360 Now an AppBar widget is simply a bit of pre-built material design, and it adds a top up bar to your app. 40 41 00:03:11,430 --> 00:03:16,860 And if we take a look at the AppBar class, it tells us there's all sorts of things that you can change 41 42 00:03:16,920 --> 00:03:17,780 about the AppBar. 42 43 00:03:17,820 --> 00:03:24,480 For example, it could have a title, or it could have a button on the left, or it could have multiple buttons 43 44 00:03:24,480 --> 00:03:28,290 on the right, or could have a bottom or a flexible space. 44 45 00:03:28,290 --> 00:03:30,860 So we're not gonna make our AppBar that complicated. 45 46 00:03:31,110 --> 00:03:38,160 And it also has a whole bunch of properties that you can change. Such as it's background color, or its 46 47 00:03:38,250 --> 00:03:39,750 brightness. 47 48 00:03:39,750 --> 00:03:44,200 Let's go ahead and first add a title to our AppBar. 48 49 00:03:44,340 --> 00:03:50,460 So we're going to happen to the title property, and we're going to give it a title. And our title is going 49 50 00:03:50,460 --> 00:03:57,360 to be made up of a text widget. And we're simply going to write the title for our app, which is 'I Am 50 51 00:03:57,450 --> 00:03:58,920 Rich' 51 52 00:03:58,970 --> 00:04:06,980 So now let's go ahead and run our app. And you can see, we have something that looks a little bit more 52 53 00:04:06,980 --> 00:04:08,500 like a real app now. 53 54 00:04:08,720 --> 00:04:16,610 It's got a real AppBar, it's got a title for the AppBar, and it's got a body, that's kind of just blank 54 55 00:04:16,670 --> 00:04:19,520 at the moment. On the top right corner, 55 56 00:04:19,520 --> 00:04:21,020 you see this little banner here. 56 57 00:04:21,140 --> 00:04:28,130 And it says debug. It's basically telling you that whatever is running at the moment, is not the final 57 58 00:04:28,190 --> 00:04:30,300 version of the app. 58 59 00:04:30,440 --> 00:04:36,550 And when you finally build your app and run it on a real device, then that little banner will go away. 59 60 00:04:36,710 --> 00:04:42,350 But when it's in the debug mode, it's there to tell you that this is not the fastest version of the app. 60 61 00:04:42,410 --> 00:04:44,080 It might have a few lags. 61 62 00:04:44,090 --> 00:04:49,330 It's not optimized. It's just for development and debugging. 62 63 00:04:49,340 --> 00:04:55,070 Now if that little banner bothers you, a really quick way of getting rid of it is by going into the Flutter 63 64 00:04:55,070 --> 00:05:02,600 Inspector, while your app is running, and going into the more actions button, and you can click on hide 64 65 00:05:02,690 --> 00:05:10,300 debug mode banner. And it will just make that disappear for you, like some sort of mafia boss. Now that 65 66 00:05:10,300 --> 00:05:11,750 we've got our app bar, 66 67 00:05:12,370 --> 00:05:18,070 And in the docs, you can see that the app bar has a whole bunch of things that we can change about it. 67 68 00:05:18,130 --> 00:05:22,580 For example it's title, and we did in fact give it a title. 68 69 00:05:22,600 --> 00:05:28,990 You can also add buttons to it. But you can also scroll down to see all of the possible properties that 69 70 00:05:28,990 --> 00:05:30,410 you can change. 70 71 00:05:30,520 --> 00:05:35,440 And one of the ones that I'm quite keen on changing is the background color of my app bar. 71 72 00:05:35,440 --> 00:05:37,390 I don't really want it to be blue. 72 73 00:05:37,390 --> 00:05:43,540 I kind of want it to be a fancier blue. And very often, your client will say things like, "That color doesn't 73 74 00:05:43,540 --> 00:05:45,310 feel classy enough. 74 75 00:05:45,430 --> 00:05:46,770 Give me a classy color." 75 76 00:05:46,810 --> 00:05:48,660 So let's give them a classy color. 76 77 00:05:48,730 --> 00:05:54,840 So in order to change the background color of our app bar, we can take a look at its properties. 77 78 00:05:54,970 --> 00:06:00,340 And one of those properties looks suspiciously like it's going to do exactly what it is that we want. 78 79 00:06:00,940 --> 00:06:06,670 And we can read the description or it says this is the color that's going to be used for the app bar's 79 80 00:06:06,730 --> 00:06:07,770 material. 80 81 00:06:07,780 --> 00:06:11,560 So that seems pretty much like what we need to change the background color, 81 82 00:06:11,560 --> 00:06:11,830 right? 82 83 00:06:12,430 --> 00:06:15,980 So let's go ahead and do that. Now for the app bar, 83 84 00:06:16,000 --> 00:06:22,480 you can see at the moment, it's got one property set, which is the title property. And the title property 84 85 00:06:22,630 --> 00:06:30,160 expects a widget. Some sort of widget that will be displayed in that position of the title in the app bar. 85 86 00:06:30,790 --> 00:06:35,320 But the property that we want to add is called backgroundColor. 86 87 00:06:35,320 --> 00:06:40,120 And this particular property expects something that is a color. 87 88 00:06:40,780 --> 00:06:42,700 So how can we put a color in here? 88 89 00:06:43,060 --> 00:06:50,170 Well, when you're creating a material app, as I mentioned, you get access to a whole bunch of material 89 90 00:06:50,170 --> 00:06:55,140 widgets, but you also get access to all of the material colors. 90 91 00:06:55,240 --> 00:07:02,710 So when Google came up with the material design system, they also came up with a color palette for you 91 92 00:07:02,710 --> 00:07:03,710 to use. 92 93 00:07:03,940 --> 00:07:11,440 And if you take a look at this page you can see all of the material colors. And they have different shades, 93 94 00:07:11,680 --> 00:07:18,160 darker or lighter or accent tones that look just a little bit brighter, and a little bit more catchy. 94 95 00:07:18,730 --> 00:07:26,230 And you have access to all of these colors straight away, by making your app a material app. If you want 95 96 00:07:26,230 --> 00:07:28,670 to go and change the color, 96 97 00:07:28,930 --> 00:07:37,270 you can tap into colors, and this will tap into all of the material colors. And then you add a '.' and 97 98 00:07:37,270 --> 00:07:39,610 you get to choose which color you want. 98 99 00:07:39,610 --> 00:07:48,110 So in our case, I'm going to make the app bar a blue-grey color. And this looks kind of like this. 99 100 00:07:48,340 --> 00:07:51,570 And I want it to be a kind of dark shade of blue grey. 100 101 00:07:51,760 --> 00:07:56,090 So I quite fancy this blueGrey 900. 101 102 00:07:56,110 --> 00:07:57,880 So that's what I'm going to type in here. 102 103 00:07:57,880 --> 00:08:04,480 I'm going to type blueGrey, and then inside some square brackets, I'm going to write 900. 103 104 00:08:04,480 --> 00:08:15,820 So now, if I run my app again you'll notice that the background of the app are changes to a dark blue 104 105 00:08:15,820 --> 00:08:16,250 color. 105 106 00:08:16,540 --> 00:08:18,670 And it looks a lot classier. 106 107 00:08:18,670 --> 00:08:20,240 I hope you might agree. 107 108 00:08:20,260 --> 00:08:24,250 Now we've got our app bar and it's looking pretty nice. 108 109 00:08:24,250 --> 00:08:31,460 The next thing to change is the main body of our app. Going back to our scaffold class, 109 110 00:08:31,480 --> 00:08:36,570 you can see that the app bar is one of the things that we can change about it. 110 111 00:08:36,760 --> 00:08:41,370 But it's also got the body, which is the primary content of the scaffold. 111 112 00:08:41,380 --> 00:08:46,040 It's everything that's going to go in here pretty much. 112 113 00:08:46,150 --> 00:08:51,340 Let's go ahead and provide a widget for it, so that we can actually show something there. 113 114 00:08:51,460 --> 00:08:54,040 Now inside are scaffold, 114 115 00:08:54,100 --> 00:08:58,470 we have a single property that we've said, which is the apple. 115 116 00:08:58,630 --> 00:09:06,520 And for the app bar position of our scaffold, we've created an actual app bar widget. Inside that widget, 116 117 00:09:06,520 --> 00:09:09,360 we've changed two of its properties. 117 118 00:09:09,460 --> 00:09:14,710 1. We've given it a title to say, "I Am Rich" as a piece of text widget. 118 119 00:09:14,710 --> 00:09:21,060 2. And we've also set the background color of our app bar widget, to a dark blue gray color. 119 120 00:09:21,160 --> 00:09:28,060 What if I wanted to change the entire background of my scaffold, so that this is no longer white but 120 121 00:09:28,120 --> 00:09:31,370 a nice sort of standard blue grey color? 121 122 00:09:31,450 --> 00:09:33,260 How can I do that? 122 123 00:09:33,280 --> 00:09:40,300 So as a challenge, I want you to look through the documentation of the scaffold widget, and see if you 123 124 00:09:40,300 --> 00:09:47,230 can figure out how to change the background color of our scaffold. Pause the video, and try to complete this 124 125 00:09:47,230 --> 00:09:49,880 challenge. 125 126 00:09:50,100 --> 00:09:57,550 All right. So let's first try and find the scaffold class in the documentation. And we can read a little 126 127 00:09:57,550 --> 00:09:59,020 bit about what it does. 127 128 00:09:59,140 --> 00:10:04,720 But more importantly, if we scroll down we can see that there's a whole bunch of properties or things 128 129 00:10:04,720 --> 00:10:09,320 that we can change and customize for our particular scaffold. 129 130 00:10:09,340 --> 00:10:14,200 Now we've already added an app bar, but we now want a background color. 130 131 00:10:14,680 --> 00:10:21,700 So this is going to change the entire scaffold background color. And we can do that by simply adding 131 132 00:10:21,700 --> 00:10:24,750 it as another property that we set. 132 133 00:10:24,820 --> 00:10:31,120 If we collapse the app bar part, you can see that in our scaffold widget, we've set a single property 133 134 00:10:31,480 --> 00:10:32,490 could AppBar. 134 135 00:10:32,620 --> 00:10:40,150 But, what if we wanted to add another property. Let's add the background color property in here. And we 135 136 00:10:40,150 --> 00:10:44,860 can provide a color using Colors.blueGrey 136 137 00:10:45,730 --> 00:10:55,840 And now, if I hit run, you can see that the entirety of my background has turned into this blue-grey color, 137 138 00:10:56,230 --> 00:11:01,710 because I've changed that property called background color for my scaffold widget. 138 139 00:11:01,900 --> 00:11:09,370 It's through the use of different widgets, different types of widgets, such as layout widgets or components 139 140 00:11:09,460 --> 00:11:16,750 such as app bars, and then by setting the properties for each of these widgets, that we start to customize 140 141 00:11:17,080 --> 00:11:21,210 the appearance and the functionality of our apps. 141 142 00:11:21,260 --> 00:11:25,820 Now all we need is to actually have some content in our app. Right? 142 143 00:11:25,820 --> 00:11:31,430 There's currently nothing in app, other than an app bar, and a blank background. 143 144 00:11:32,420 --> 00:11:38,480 If we look at the scaffold class again, you can see that in the example code, the example shows a scaffold 144 145 00:11:38,720 --> 00:11:45,550 with an AppBar, BottomAppBar and a FloatingActionButton. And then it talks about the body. 145 146 00:11:45,640 --> 00:11:51,120 Now the body, is where the primary content of the scaffold is gonna go. 146 147 00:11:51,190 --> 00:11:59,200 And that refers to this area right here. And you can see that when you set the body property, it's expecting 147 148 00:11:59,380 --> 00:12:01,450 a widget to be set there. 148 149 00:12:01,570 --> 00:12:03,470 Let's go ahead and do that. 149 150 00:12:03,490 --> 00:12:12,190 Let's firstly add a property, that's the body property, and we're going to provide a widget right here. 150 151 00:12:12,190 --> 00:12:18,280 The widget that I'm gonna use is going to be an image widget, and you can creat it by writing the word 151 152 00:12:18,310 --> 00:12:20,330 image and a set of parentheses. 152 153 00:12:20,590 --> 00:12:26,120 And inside the parentheses, we get to define what type of image we're going to show. 153 154 00:12:26,140 --> 00:12:36,640 So for the body of my scaffold, I'm going to add a image widget, and the image widget is almost like a 154 155 00:12:36,640 --> 00:12:45,080 picture frame. You create it and it starts out blank. But you can change one of its properties. 155 156 00:12:45,130 --> 00:12:50,590 Now when we search for the documentation for the image class, for example if I type it in here, you'll 156 157 00:12:50,590 --> 00:12:55,210 notice that there's actually two different images that we could be tapping into. 157 158 00:12:55,240 --> 00:12:57,750 One, is an image from Dart, 158 159 00:12:57,970 --> 00:13:01,030 and another is an image from widgets. 159 160 00:13:01,030 --> 00:13:07,030 Now because we want an actual image widget, because it will show up on screen, then we want to look at 160 161 00:13:07,030 --> 00:13:10,270 the documentation for that particular selection. 161 162 00:13:10,300 --> 00:13:16,150 So this is just the tip to remember that when you're searching in the search box for the documentation, 162 163 00:13:16,330 --> 00:13:22,630 there might be multiple things that are named the same, but they come from different libraries of code. 163 164 00:13:22,630 --> 00:13:27,820 And if you're putting something on screen that's gonna show up, it's always going to be a widget. In our 164 165 00:13:27,940 --> 00:13:29,170 image class, 165 166 00:13:29,170 --> 00:13:34,640 you can see that there's a whole bunch of different ways of creating a new image. 166 167 00:13:34,870 --> 00:13:44,200 And we can either create an image from our asset bundle, or we can create an image from a file, or we 167 168 00:13:44,200 --> 00:13:47,050 can create an image from the network. 168 169 00:13:47,230 --> 00:13:51,220 So the image class is actually just a placeholder. 169 170 00:13:51,250 --> 00:13:57,820 It's like a picture frame that we put onto the screen, and it doesn't come with an image by default. 170 171 00:13:57,820 --> 00:14:05,680 Instead, we have to use one of its properties. For example the image property to tell it what image it 171 172 00:14:05,680 --> 00:14:07,690 should display. 172 173 00:14:07,690 --> 00:14:13,500 Here is all image widget, and we're going to set it's image property. 173 174 00:14:13,600 --> 00:14:17,080 Now there's different types of images that we can display. 174 175 00:14:17,140 --> 00:14:24,280 We can either display an asset image, that's an image that comes from our project folders, or we can display 175 176 00:14:24,370 --> 00:14:27,660 a network image that comes from the Internet. 176 177 00:14:27,700 --> 00:14:35,730 So let's try this one first you can see that this particular widget expects a URL, and this has to 177 178 00:14:35,730 --> 00:14:42,450 be a URL that corresponds to an image, so that it will show up inside our image picture frame. 178 179 00:14:42,450 --> 00:14:52,630 If we go on to Google and we just search for image, we go in to images. Then let's pick one of these images, 179 180 00:14:52,640 --> 00:14:56,680 let's say this one some northern lights to go into an app. 180 181 00:14:56,990 --> 00:15:06,530 If we right click on the image and we say open image in new tab, then it will open it with URL 181 182 00:15:06,530 --> 00:15:10,280 that we need to fetch this particular image. 182 183 00:15:10,290 --> 00:15:12,420 Notice that there's nothing else on screen. 183 184 00:15:12,450 --> 00:15:15,470 This is just where the image resides. 184 185 00:15:15,510 --> 00:15:19,970 So let's copy that URL, and paste it inside here. 185 186 00:15:20,370 --> 00:15:29,790 In order to use text, not code, but actual strings, we have to add some single quotes around the text. so 186 187 00:15:29,880 --> 00:15:30,720 we will paste 187 188 00:15:30,720 --> 00:15:33,750 our URL inside two single quotes. 188 189 00:15:34,080 --> 00:15:40,650 And while in other programming languages, such as Swift or Java, we'll be using double quotes. When we're 189 190 00:15:40,650 --> 00:15:41,780 writing Dart code, 190 191 00:15:41,820 --> 00:15:48,090 by convention, we should work always with single quotes at the end and at the beginning. 191 192 00:15:48,180 --> 00:15:56,190 Now we're telling our app that it should display an image in the main body of our scaffold, and the image 192 193 00:15:56,220 --> 00:16:00,290 that it should display is going to be one that's fetched from the Internet. 193 194 00:16:00,960 --> 00:16:05,820 And the place where that image resides is right here. 194 195 00:16:05,820 --> 00:16:15,470 So now if we hit play, and we run our app, then you can see it shows up our image right in there in the 195 196 00:16:15,470 --> 00:16:20,360 body of our app. Here's a challenge, at the moment, 196 197 00:16:20,460 --> 00:16:23,620 our image is right at the top of our app. 197 198 00:16:23,760 --> 00:16:31,530 Can you make it such that the image is centered inside the body of our scaffold? 198 199 00:16:31,530 --> 00:16:39,670 You've seen this before. Pause the video and try to complete this challenge. As we saw before, 199 200 00:16:39,850 --> 00:16:46,920 if we want to center a widget inside another widget, we can use the center widget. 200 201 00:16:46,920 --> 00:16:54,010 And in order to do that, we would have to wrap the image widget inside a center widget. 201 202 00:16:54,010 --> 00:17:00,850 Now we can either do that by, what we did before, which is where we cut out that widget put in the center 202 203 00:17:00,850 --> 00:17:07,000 widget, and then inside the center widget we told it what's going to be the child or the thing that's 203 204 00:17:07,210 --> 00:17:08,620 going to be centered. 204 205 00:17:08,800 --> 00:17:13,370 And then we paste it in, the thing that needed to be in the center. 205 206 00:17:13,390 --> 00:17:19,660 Now there's a much easier way that I want to show you. I've reversed the code back to what we had before. 206 207 00:17:19,800 --> 00:17:28,470 And if you click on the widget that you want to embed in another widget, and you either click on the 207 208 00:17:28,470 --> 00:17:37,140 little yellow light bulb that shows up, or hold down ALT on Windows, or OPTION on Mac, and hit ENTER. You'll 208 209 00:17:37,140 --> 00:17:44,430 see a little menu pop up. And this will menu makes it really convenient for you to embed the current 209 210 00:17:44,430 --> 00:17:47,620 thing that's selected inside something else. 210 211 00:17:47,760 --> 00:17:54,360 So we can wrap it with a column, wrap it with a row, put it in a new container and also put it in a center 211 212 00:17:54,360 --> 00:18:03,270 widget. And that automatically puts in the center widget, adds in a child property, and puts our previous 212 213 00:18:03,270 --> 00:18:06,720 widget that we had selected, inside there. 213 214 00:18:06,720 --> 00:18:15,120 So now when we run our app again, you'll see that our image gets automatically centered in the body of 214 215 00:18:15,170 --> 00:18:23,180 our scaffold, which is exactly what we told it to do. So we now have a really simple app that's written 215 216 00:18:23,180 --> 00:18:28,300 with very few lines of code. But it actually does quite a lot of powerful stuff. 216 217 00:18:28,340 --> 00:18:34,670 It's laid out and created a new app structure for us using the scaffold. 217 218 00:18:34,670 --> 00:18:41,870 We provided an app bar and set the background color of our apple to a color that comes from the material 218 219 00:18:41,870 --> 00:18:44,890 palette which is this dark blue-grey color. 219 220 00:18:44,960 --> 00:18:52,790 We gave it a title using a text widget and then we added a body property to our scaffold to tell it 220 221 00:18:52,820 --> 00:18:56,210 what it should display in the main body of the app. 221 222 00:18:56,240 --> 00:19:03,460 And here we have an image that's fetched from the Internet using a URL, where that image lives. 222 223 00:19:04,220 --> 00:19:12,200 And then we centered that widget using our convenient menu, and we now have an app that does pretty complicated 223 224 00:19:12,200 --> 00:19:18,940 things especially for how few lines of code we've written. So it's a good time to review the structure 224 225 00:19:19,060 --> 00:19:20,650 of our current app. 225 226 00:19:20,650 --> 00:19:25,990 And I'm gonna go onto a website called draw.io which makes it really easy to create flow charts 226 227 00:19:25,990 --> 00:19:33,420 and diagrams. And I'm going to create a diagram for my 'I Am Rich' app. Let's start from the beginning. We 227 228 00:19:33,420 --> 00:19:41,250 have a Material App, right at the top of the tree. So let's drag in a rounded rectangle, and let's call 228 229 00:19:41,250 --> 00:19:43,600 it Material App. 229 230 00:19:43,740 --> 00:19:50,960 Now that material app has a single item that's embedded inside it, and that's a scaffold. 230 231 00:19:51,090 --> 00:19:59,750 So let's add that as a descendant, and that's going to be our scaffold. And inside the scaffold, 231 232 00:19:59,750 --> 00:20:03,210 we've got a couple of things. We've got a app bar, 232 233 00:20:03,440 --> 00:20:11,460 we've got a body, and we've got a background color. so the background color is a color widget. Let's 233 234 00:20:11,580 --> 00:20:12,970 add that here. 234 235 00:20:13,290 --> 00:20:17,520 We've got a color widget and we've got an app bar widget, 235 236 00:20:21,230 --> 00:20:27,330 and finally we've got a center widget. 236 237 00:20:27,360 --> 00:20:32,940 These are the three children or descendants of our scaffold. 237 238 00:20:32,940 --> 00:20:36,810 And then these widgets each have their own children. 238 239 00:20:36,930 --> 00:20:40,830 So the center widget has an image as a child, 239 240 00:20:41,100 --> 00:20:43,110 so let's add that. 240 241 00:20:43,770 --> 00:20:47,960 And remember we said that the image widget is kind of just like a picture frame. 241 242 00:20:48,090 --> 00:20:52,080 And it has to have some content for it to actually display something. 242 243 00:20:52,080 --> 00:20:59,610 So the image widget actually has a child that is a network image, because it has to fetch the image from 243 244 00:20:59,790 --> 00:21:00,720 the Internet. 244 245 00:21:00,900 --> 00:21:07,820 And the app bar has two children, a title that's a text widget, and a background color, 245 246 00:21:07,830 --> 00:21:09,960 that's another color widget. 246 247 00:21:09,960 --> 00:21:12,360 So let's add that in there as well. 247 248 00:21:12,360 --> 00:21:21,980 So we've got a text widget and a color widget. And this is all widget tree. By embedding widgets inside 248 249 00:21:22,010 --> 00:21:26,630 other widgets, and setting the properties of each of these widgets, 249 250 00:21:26,690 --> 00:21:33,100 we've ended up creating an app that actually looks like it's almost ready for the app store. 250 251 00:21:33,140 --> 00:21:38,840 There's certainly a lot simpler apps that I've seen, and all that we've written is just twenty two lines 251 252 00:21:38,840 --> 00:21:46,940 of code. But we've effectively created an iOS app and an Android app that has an image, that has an app 252 253 00:21:46,950 --> 00:21:50,880 bar, that has backgrounds, that has a whole lot of things. 253 254 00:21:50,990 --> 00:21:58,070 All because we're leveraging the power of these pre-built widgets from Flutter. And in the next lesson, 254 255 00:21:58,130 --> 00:22:04,820 we're going to learn about another type of widget that will allow us to load images from our assets 255 256 00:22:04,820 --> 00:22:09,320 folder in our project, and display it inside our app. 256 257 00:22:09,330 --> 00:22:12,230 So for all of that and more, I see on the next lesson. 29504

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.