All language subtitles for 8. Adding Material Icons with the Icon Widget

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 Download
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,510 --> 00:00:00,780 All right. 1 2 00:00:00,810 --> 00:00:07,110 So we've already gotten pretty far. But the next thing that I want to create are these little boxes. These 2 3 00:00:07,110 --> 00:00:14,250 boxes that contain an icon and also a phone number or an email address, whatever it is that you want 3 4 00:00:14,250 --> 00:00:15,550 to show. 4 5 00:00:15,570 --> 00:00:23,070 Now you can use an image asset as an icon. But it's nowhere near as adaptable as simply using an icon 5 6 00:00:23,070 --> 00:00:23,490 widget. 6 7 00:00:24,110 --> 00:00:26,600 And I want to show you how this works. 7 8 00:00:27,060 --> 00:00:33,570 If we collapse both of our text widgets and our circle avatar, then we can see that in our column, we 8 9 00:00:33,570 --> 00:00:38,660 currently have three things, our circle avatar, our text which is our name, 9 10 00:00:38,700 --> 00:00:41,810 and finally, the job title that we have here. 10 11 00:00:42,030 --> 00:00:51,020 So I'm gonna go ahead and add another child and this is gonna be a container. Now inside this container, 11 12 00:00:51,020 --> 00:00:54,520 the only child that it's gonna have is a row. 12 13 00:00:54,920 --> 00:00:59,810 And very often when you're creating user interfaces in Flutter, you'll find yourself embedding rows 13 14 00:00:59,810 --> 00:01:02,660 inside columns or columns inside rows. 14 15 00:01:02,660 --> 00:01:08,440 And this gives you that kind of grid layout pattern that makes your layout really flexible. 15 16 00:01:08,480 --> 00:01:14,660 We're going to have a fourth child which is going to be a row, and this row is going to have a whole 16 17 00:01:14,660 --> 00:01:26,270 bunch of children including an icon. Now an icon is a class that is drawn instead of being shown. 17 18 00:01:26,270 --> 00:01:29,780 So for an image it's simply displayed as is. 18 19 00:01:29,780 --> 00:01:35,390 But for an icon, it's actually drawing all of the sides and the edges onto the screen. 19 20 00:01:35,390 --> 00:01:42,380 What this allows you to do, is you can on the fly for example, change the color of the icon or the size 20 21 00:01:42,380 --> 00:01:43,420 of the icon. 21 22 00:01:43,580 --> 00:01:47,910 And it's so much more flexible than simply just using an image. 22 23 00:01:48,140 --> 00:01:56,000 And by using the material.dart package from Flutter, you already have access to a whole bunch of icons 23 24 00:01:56,090 --> 00:02:03,690 that Google made. So, if you take a look at the documentation for the icons class, icons with an s, you 24 25 00:02:03,690 --> 00:02:11,880 can see that you have all of these icons at your fingertips. And they come from the material design icons. 25 26 00:02:11,910 --> 00:02:18,750 So these are icons that designers at Google actually created, so you can have a consistent theme across 26 27 00:02:18,810 --> 00:02:25,650 apps that are built with the material design look. The way that I prefer to browse icons is actually 27 28 00:02:25,650 --> 00:02:28,310 using a tool called materialpalette.com. 28 29 00:02:28,950 --> 00:02:35,250 And not only is this really good for coming up with really intelligent beautiful color palettes. So for 29 30 00:02:35,250 --> 00:02:43,200 example on the main page, if you select two colors that you quite like, for example teal and yellow, then 30 31 00:02:43,200 --> 00:02:49,530 it'll automatically generate you a eight-color color palette even complete with an accent tone. And you 31 32 00:02:49,530 --> 00:02:56,730 can see it looks really really nice straight up from the get go. And it also has the colors that we've 32 33 00:02:56,730 --> 00:03:00,820 been using so far and gives you their names all in one place. 33 34 00:03:01,010 --> 00:03:06,200 And if you click on them, it'll show you all the various shades that you can tap into. 34 35 00:03:06,400 --> 00:03:13,170 There's also a third tab which are the icons. And it's a really easily searchable place where you can 35 36 00:03:13,170 --> 00:03:19,640 say let's look for an add icon, and it shows you here are all the ones that you could possibly use. 36 37 00:03:19,830 --> 00:03:22,950 And when you find one of them, you can see it has a name. 37 38 00:03:22,950 --> 00:03:23,520 Right. 38 39 00:03:23,520 --> 00:03:30,930 This one's called add_shopping.cart. So I can simply go into my Flutter app and write icons, which 39 40 00:03:30,930 --> 00:03:35,650 is the name of the class that supports material design icons. 40 41 00:03:36,000 --> 00:03:48,000 .add_shopping_cart. And now, almost immediately, you can see that I can add that icon that I found on 41 42 00:03:48,000 --> 00:03:51,750 here to my app. Which is brilliant, 42 43 00:03:51,750 --> 00:04:00,270 if you don't want to spend a lot of time finding or creating or paying for these design resources. 43 44 00:04:00,270 --> 00:04:05,750 Now I mentioned that icons are better than images because they're drawn on the fly. 44 45 00:04:05,760 --> 00:04:11,100 So let me show you what you can do with these icons that you can't do with images. 45 46 00:04:11,100 --> 00:04:17,730 I can for example turn that icon into a much larger icon by simply changing its size property. 46 47 00:04:17,730 --> 00:04:26,590 So let's make it 100, and you can see that almost immediately, my icon becomes super large and the 47 48 00:04:26,590 --> 00:04:30,100 lines get thicker and it scales until infinity. 48 49 00:04:30,100 --> 00:04:36,520 So if I change this to 1000, you'll see that it won't pixelate because it's actually just drawn. 49 50 00:04:36,730 --> 00:04:42,910 All that happens, is that it goes off the screen, and you get these yellow bars as a warning to tell you 50 51 00:04:42,910 --> 00:04:48,580 that there's parts of your content that's not visible to the user. It's completely off the screen but you 51 52 00:04:48,580 --> 00:04:55,120 can see that this icon doesn't become pixelated, whereas if I did that to my image up here. 52 53 00:04:55,200 --> 00:05:03,250 So let's say I make that circle avatar 1000 in its radius. Then you can see that my picture becomes a 53 54 00:05:03,250 --> 00:05:06,810 little bit pixelated. And let's go a little bit more extreme, 54 55 00:05:06,820 --> 00:05:11,800 let's add another zero to that, and now it's completely not interpretable. 55 56 00:05:11,800 --> 00:05:15,330 I can't really tell what that is anymore even though I know it's her. 56 57 00:05:15,400 --> 00:05:22,030 This is the reason why icons are much better because they're vectors, and you can even change their color 57 58 00:05:22,090 --> 00:05:23,240 on the fly. 58 59 00:05:23,320 --> 00:05:30,380 Let's change the color of my icon to that teal color that we've been using. Just save 59 60 00:05:30,520 --> 00:05:39,040 and you can see it now blurs into the background. But if I change that into a 900 shade, and it save, then 60 61 00:05:39,100 --> 00:05:42,620 you'll see it become a much darker teal. 61 62 00:05:42,620 --> 00:05:44,980 And now it's completely visible. 62 63 00:05:44,980 --> 00:05:47,140 So you can change the color of it. 63 64 00:05:47,170 --> 00:05:49,600 You can change the size of it. 64 65 00:05:49,630 --> 00:05:54,490 You can do all sorts of things with these icons that you can't do with images. 65 66 00:05:54,490 --> 00:05:59,530 And this is why they're really really useful inside your app. 66 67 00:05:59,530 --> 00:05:59,800 All right. 67 68 00:05:59,800 --> 00:06:05,200 So the icon that we actually want here is the one called phone. 68 69 00:06:05,200 --> 00:06:11,890 And this one gives us that little phone icon that we can put next to some piece of text. 69 70 00:06:11,890 --> 00:06:19,780 So in addition to the icon, I'm also going to have some text and this is simply going to be a phone number. 70 71 00:06:19,810 --> 00:06:25,720 So +44 123 456 789 for example. 71 72 00:06:25,960 --> 00:06:31,170 And then I'm going to style up my text because at the moment it looks a bit boring. 72 73 00:06:31,330 --> 00:06:40,690 So I'm going to give it a text style. And this is going to have a color which is going to be a dark teal 73 74 00:06:40,690 --> 00:06:41,010 color. 74 75 00:06:41,020 --> 00:06:49,510 So colors.teal.shade900 and then it's going to have a font family of the same one 75 76 00:06:49,510 --> 00:06:52,150 that we've been using which is Source Sans 76 77 00:06:52,200 --> 00:07:01,610 Pro. And we can change the font size to 20 points, and let's hit save and see what that looks like. 77 78 00:07:01,610 --> 00:07:01,840 All right. 78 79 00:07:01,880 --> 00:07:06,920 So that looks pretty nice but it'd be nice if there was a little bit of space between the icon and the 79 80 00:07:06,920 --> 00:07:07,640 text right. 80 81 00:07:08,120 --> 00:07:14,510 Well we know that we are inside a row, and the way that we can easily add space between our children 81 82 00:07:14,630 --> 00:07:18,840 in our rows, is by adding a sized box. 82 83 00:07:18,890 --> 00:07:25,160 So we're going to add a sized box and we're going to give it some dimension in the horizontal axis. 83 84 00:07:25,160 --> 00:07:25,420 Right. 84 85 00:07:25,430 --> 00:07:28,600 Because we're in a row, so it's going to go from left to right. 85 86 00:07:28,610 --> 00:07:33,710 So we'll give it a width, and let's give it a width of maybe 10 points. 86 87 00:07:33,710 --> 00:07:36,890 And that should be enough to separate those out a little bit. 87 88 00:07:36,890 --> 00:07:39,620 Make it look just that bit nicer. 88 89 00:07:39,620 --> 00:07:45,890 So finally I'm going to give my container a color just so that it will show up as a separate piece of 89 90 00:07:45,890 --> 00:07:49,210 information, from the rest of my widgets. 90 91 00:07:49,250 --> 00:07:59,200 So let's give this a color of white, and let's hit save, and now I have to change my icon back into teal 91 92 00:07:59,200 --> 00:08:05,890 so that it's visible. And I can make it come away from the edges of the screen a little bit by adding 92 93 00:08:06,430 --> 00:08:07,110 margin. 93 94 00:08:07,390 --> 00:08:14,440 So a lot of the widgets inside Flutter will have margin or padding as properties that you can change. 94 95 00:08:15,010 --> 00:08:19,780 And they all work exactly the same way as we saw earlier with the columns and the rows. 95 96 00:08:20,200 --> 00:08:26,410 We use edgeinsets and I'm going to add edgeinsets only that are different for the top and bottom and 96 97 00:08:26,410 --> 00:08:27,950 also left and right. 97 98 00:08:28,000 --> 00:08:36,460 So I'm going to use some metric. And I'm going to say that the vertical sides, so the top and bottom, are 98 99 00:08:36,460 --> 00:08:44,400 going to have 10 points of margin and the horizontal is going to have 25 points of margin. 99 100 00:08:44,440 --> 00:08:51,190 Now you can see that our container comes away a little bit from the edges, and it looks just a little 100 101 00:08:51,190 --> 00:08:55,810 bit better. And our container also has padding. 101 102 00:08:55,810 --> 00:09:05,450 So let's add maybe 10 pixels of padding to all four sides. And now we have our little card. 102 103 00:09:05,500 --> 00:09:06,250 Right. 103 104 00:09:06,630 --> 00:09:13,290 As a challenge I want you to create the other container. The one where you have your email address and 104 105 00:09:13,290 --> 00:09:14,430 an email icon. 105 106 00:09:14,910 --> 00:09:20,880 So I want to challenge you to use the Flutter documentation, and also what you learned in this lesson 106 107 00:09:21,180 --> 00:09:28,800 to create that second card. Pause the video, and give that a go now. OK, 107 108 00:09:28,820 --> 00:09:31,980 so we know that we need another container. 108 109 00:09:31,980 --> 00:09:32,340 Right. 109 110 00:09:32,340 --> 00:09:34,860 It's pretty much the same as this one. 110 111 00:09:34,860 --> 00:09:37,580 So let's find out where our container ends. 111 112 00:09:37,610 --> 00:09:38,900 It's right about here. 112 113 00:09:39,120 --> 00:09:46,730 And let's go ahead and collapse it. And then we're going to add another container underneath it. 113 114 00:09:46,730 --> 00:09:50,590 And this one is also going to have the same amount of padding, 114 115 00:09:50,600 --> 00:09:54,520 so that was edgeinsets all with 10 points. 115 116 00:09:54,770 --> 00:10:06,900 And then it's going to have a margin of symmetric margin with 10 on the vertical, and 25 on the horizontal. 116 117 00:10:06,950 --> 00:10:12,740 And finally it's going to have some content and the content is going to be under the child property 117 118 00:10:13,250 --> 00:10:16,090 and it's going to be a row that we want to create. 118 119 00:10:16,130 --> 00:10:24,440 The row is going to have some children. And these children include, one a icon that comes from the icons 119 120 00:10:24,440 --> 00:10:30,770 class. And you can either scroll through this to find an icon that looks right. 120 121 00:10:30,770 --> 00:10:37,110 But in this case it's going to be email. Or you can take a look at the websites that we spoke about earlier 121 122 00:10:37,110 --> 00:10:38,180 on. 122 123 00:10:38,280 --> 00:10:45,000 Now that I have my e-mail icon in there, I'm going to change the styling of that icon to make it look 123 124 00:10:45,000 --> 00:10:46,700 a bit more like the other one. 124 125 00:10:46,770 --> 00:10:57,360 So I have to change its color to teal. And then I get to add my text which can really say anything you 125 126 00:10:57,360 --> 00:10:58,430 want it to. 126 127 00:10:58,440 --> 00:11:06,480 But in my case I'm going to add maybe an email. Let's say angela@email.com. And then I'm going 127 128 00:11:06,480 --> 00:11:17,220 to change its style to have a text style, and maybe we'll go for a font size of 20 to match with the 128 129 00:11:17,220 --> 00:11:23,010 other one, a color of teal 900 129 130 00:11:26,080 --> 00:11:36,630 and the font family is of course also going to be Source Sans Pro. Let's hit save and let's see if we 130 131 00:11:36,630 --> 00:11:38,400 get what we wanted. 131 132 00:11:38,580 --> 00:11:39,030 OK. 132 133 00:11:39,030 --> 00:11:41,520 So we can see that the icon has disappeared. 133 134 00:11:41,520 --> 00:11:43,480 So it's the same color as the background. 134 135 00:11:43,530 --> 00:11:49,200 We've got our text formatted in the same way as the previous one, and all we have to do now is to give 135 136 00:11:49,230 --> 00:11:58,760 our container a white background and it should show up underneath the other one and show us what else 136 137 00:11:58,760 --> 00:11:59,570 is missing. 137 138 00:11:59,570 --> 00:12:06,080 So the only thing that looks odd to me is just a little bit of space between the icon and the text. 138 139 00:12:06,080 --> 00:12:10,310 So to do that we have to add our Sized Box with a width, 139 140 00:12:11,090 --> 00:12:14,250 and that was going to be 10. 140 141 00:12:14,360 --> 00:12:21,420 And now if we hit save, then it's starting to look pretty good. In the next lesson, 141 142 00:12:21,450 --> 00:12:28,440 we're going to finalize this app, and we're gonna make these in those actions a little bit nicer looking 142 143 00:12:28,530 --> 00:12:31,500 using a Flutter widget called card. 143 144 00:12:31,500 --> 00:12:34,580 So for all of that and more, I'll see on the next lesson. 16141

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