Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:00,540 --> 00:00:07,180
Now we can see that our design is really coming together. And it's looking already pretty nice.
1
2
00:00:07,350 --> 00:00:14,190
But this just a few things that look a little bit different for our info sections here, compared to what
2
3
00:00:14,190 --> 00:00:15,910
we initially wanted.
3
4
00:00:16,140 --> 00:00:21,960
And these are really subtle things like maybe a little bit a rounding of the corners, or a little bit
4
5
00:00:21,960 --> 00:00:29,340
of shadow under the white part, to make it feel like it's popping out of the page a little bit. So we
5
6
00:00:29,340 --> 00:00:36,990
can either try and customize what we have to make it look like this, or we can simply use a pre-built
6
7
00:00:37,050 --> 00:00:43,530
widget class called card. And you might have seen this in a lot of the apps that you use from day to
7
8
00:00:43,530 --> 00:00:45,920
day, especially the ones from Google.
8
9
00:00:45,930 --> 00:00:54,510
This is a very very subtly shadowed rectangle and it has a small curve to all four edges, and it has
9
10
00:00:54,600 --> 00:00:58,330
a decent amount of padding so the contents centered on the card.
10
11
00:00:58,710 --> 00:01:04,860
And we can create this really really simply by using the card widget.
11
12
00:01:05,280 --> 00:01:10,690
Let's swap out our containers for a card widget instead.
12
13
00:01:10,920 --> 00:01:18,530
And the first thing that you'll notice is that we have some red lines. And that's because the card widget
13
14
00:01:18,840 --> 00:01:21,930
doesn't actually have a padding property.
14
15
00:01:21,930 --> 00:01:26,550
So let's go ahead and delete the padding that we've set for both of those.
15
16
00:01:26,760 --> 00:01:32,560
But other than the padding, everything else is perfectly valid. Cards have a margin that you can set.
16
17
00:01:32,700 --> 00:01:36,460
It has a child that can contain items inside here.
17
18
00:01:36,600 --> 00:01:46,260
And if I hit save right now, you can see that our info sections, automatically start looking like cards.
18
19
00:01:46,270 --> 00:01:50,140
The only problem is that our cards don't have any padding.
19
20
00:01:50,200 --> 00:01:56,920
So what can we do when we have a widget that doesn't actually have a property that we want to change
20
21
00:01:57,310 --> 00:02:01,480
because padding doesn't exist for card?
21
22
00:02:01,480 --> 00:02:08,170
But, if you look through the Flutter documentation, you might come across something called the padding
22
23
00:02:08,170 --> 00:02:09,430
class.
23
24
00:02:09,430 --> 00:02:16,670
And this is a widget that can be added as a parent to any other widget and it'll give it some padding.
24
25
00:02:16,690 --> 00:02:18,520
And this is how you might use it.
25
26
00:02:18,550 --> 00:02:25,390
So you could have a padding widget as the parent to a card widget.
26
27
00:02:25,390 --> 00:02:28,360
And now you end up with some padding around it.
27
28
00:02:29,200 --> 00:02:32,350
Now the way that you use padding is quite interesting.
28
29
00:02:32,350 --> 00:02:38,200
Let's go ahead and add our padding. And we're going to do it around our row because we're going to pad
29
30
00:02:38,200 --> 00:02:41,770
out our row inside our card.
30
31
00:02:41,770 --> 00:02:48,160
So I'm going to select or put my cursor on the row widget, and I'm going to hold down OPTION or ALT and
31
32
00:02:48,160 --> 00:02:55,210
hit ENTER, to pull up the intention actions menu. And I'm going to select wrap with new widget and that
32
33
00:02:55,210 --> 00:03:02,700
new widget is of course going to be padding. And padding of course has a padding property,
33
34
00:03:02,700 --> 00:03:08,320
and we're going to set it to EdgeInsets.all with 25 points of padding.
34
35
00:03:08,320 --> 00:03:14,180
Now you can see that we have all this massive space around our row.
35
36
00:03:14,220 --> 00:03:18,710
So the padding goes around it's child.
36
37
00:03:18,900 --> 00:03:26,010
It's almost like we're adding a soft blanket around which ever widget it is, that we've wrapped our padding.
37
38
00:03:27,360 --> 00:03:30,560
In our case, that's our row.
38
39
00:03:30,650 --> 00:03:36,830
And so the row now exists inside a 25 point padding.
39
40
00:03:36,830 --> 00:03:45,010
Now, what would you think would have happened had we put our padding around our card instead? Well in
40
41
00:03:45,010 --> 00:03:45,820
that case,
41
42
00:03:46,150 --> 00:03:50,790
we can remove our widget from our row, and we can add it to our card.
42
43
00:03:50,830 --> 00:03:56,290
And you can see that adding padding around widgets is such a common action that you can actually select it
43
44
00:03:56,310 --> 00:04:02,710
in this menu already. And you can select that, and it comes pre-built with a certain amount of padding.
44
45
00:04:02,710 --> 00:04:11,950
So let's change that to 25. And you can see that when the padding goes around the card, it doesn't actually
45
46
00:04:11,950 --> 00:04:18,370
achieve what it is that we wanted, which is to get a slightly larger card with a bit of space between
46
47
00:04:18,370 --> 00:04:21,440
the edges of the card and the actual content.
47
48
00:04:21,490 --> 00:04:29,260
But in this case what's actually happened, is the padding has gone around our card and it almost looks
48
49
00:04:29,260 --> 00:04:32,260
like we've added margins around our card.
49
50
00:04:32,980 --> 00:04:38,830
It's important to remember that when you're adding padding, the child of the padding widget is going to
50
51
00:04:38,830 --> 00:04:45,160
get a blanket essentially wrapped around it and separated from everything else.
51
52
00:04:45,280 --> 00:04:47,620
I'm going to go ahead and delete that padding.
52
53
00:04:50,910 --> 00:04:57,160
And I want to show you that not only can we use the card widget to make our lives easier,
53
54
00:04:57,300 --> 00:05:03,970
we can even get rid of our row widget by using something that's used very commonly with cards in Flutter.
54
55
00:05:04,380 --> 00:05:10,320
And it's used so commonly that they even mention it in the documentation. Whenever you're looking at
55
56
00:05:10,320 --> 00:05:13,320
documentation on the Flutter website,
56
57
00:05:13,500 --> 00:05:16,410
there's usually a section called see also.
57
58
00:05:17,010 --> 00:05:23,730
And this very helpfully points you towards other widgets that are used really commonly with this widget.
58
59
00:05:23,910 --> 00:05:27,450
And here, it points to something called a list tile.
59
60
00:05:27,630 --> 00:05:31,530
And this displays icons and text in a card.
60
61
00:05:31,530 --> 00:05:34,640
Well that sounds pretty much like what we need
61
62
00:05:34,650 --> 00:05:34,980
right?
62
63
00:05:35,520 --> 00:05:38,620
So let's click on it and see what it does.
63
64
00:05:38,640 --> 00:05:46,620
This is a single fixed-height row that typically contains some text as well as a leading or trailing icon.
64
65
00:05:46,620 --> 00:05:56,430
So that sounds like a much more convenient way of implementing all of this. Instead of having our row,
65
66
00:05:56,460 --> 00:06:00,030
we're going to use this list tile instead.
66
67
00:06:00,090 --> 00:06:06,720
So I'm going to cut the row out and I'm going to past it at the bottom for reference. And inside my card,
67
68
00:06:06,810 --> 00:06:14,490
as a child, I'm going to add a list tile. And you can see that list tiles have a number of properties.
68
69
00:06:14,850 --> 00:06:22,770
The leading area which is on the left of that row, the title which is a bit of text that we could put,
69
70
00:06:23,280 --> 00:06:25,280
it could also have a subtitle.
70
71
00:06:25,380 --> 00:06:35,420
And finally a trailing icon. Let's add our list tile, and let's give it a leading widget which is going
71
72
00:06:35,420 --> 00:06:37,130
to be our icon.
72
73
00:06:37,130 --> 00:06:43,160
So I'm going to take all of my icon and I'm going to paste it inside here.
73
74
00:06:43,790 --> 00:06:47,100
So let's get rid of that duplicate comma.
74
75
00:06:47,420 --> 00:06:51,390
And now we can add a title to our list title.
75
76
00:06:51,620 --> 00:06:54,330
And that title is of course going to be our text.
76
77
00:06:54,440 --> 00:06:57,540
So from the bottom part of our text to the top,
77
78
00:06:57,540 --> 00:07:00,660
I'm going to paste that inside here.
78
79
00:07:01,190 --> 00:07:08,810
And now we have a list tile and a piece of text, and we can delete the rest of this.
79
80
00:07:08,870 --> 00:07:10,610
So that's a lot shorter.
80
81
00:07:11,030 --> 00:07:17,090
If you hit save, and you take a look at the results, you can see that it's already got a bit of space
81
82
00:07:17,120 --> 00:07:20,300
between the leading icon and the title.
82
83
00:07:20,540 --> 00:07:27,680
And we've got a little bit of padding around our list tile, and it looks pretty great already.
83
84
00:07:28,460 --> 00:07:36,950
So as a challenge, try and reformat the other list tile so that it does exactly the same thing, and have
84
85
00:07:36,950 --> 00:07:42,110
a look through the documentation for the list tile, to see what other things you can customize about
85
86
00:07:42,110 --> 00:07:51,690
it. The only other thing that we need to change here is this card. And this card currently has a row in
86
87
00:07:51,690 --> 00:07:53,910
it which we're going to remove.
87
88
00:07:53,910 --> 00:08:01,620
So we're going to find the row comment and cut out this row, past it at the bottom in case we need it.
88
89
00:08:02,610 --> 00:08:12,270
And then we're going to add a list tile as the child, and it's going to have a leading widget which is
89
90
00:08:12,270 --> 00:08:15,820
going to be our icon, so icon.
90
91
00:08:15,900 --> 00:08:24,210
Let's put that in here, and delete the extra comma and then it's also going to have a title which is
91
92
00:08:24,210 --> 00:08:26,680
going to be our text widget here.
92
93
00:08:28,040 --> 00:08:34,770
And let's paste that in there. Now we can delete all of this, and we can hit save.
93
94
00:08:37,520 --> 00:08:47,420
Cards, by default, come with a white color. So we can delete this color property without it changing anything
94
95
00:08:47,630 --> 00:08:49,230
about our card.
95
96
00:08:49,550 --> 00:08:58,490
And you can see that we now have this vastly simplified code because we're able to use pre-built widgets
96
97
00:08:58,820 --> 00:09:06,740
that conform to the material design principles. And all we have to do is to figure out which widget to
97
98
00:09:06,740 --> 00:09:10,520
use and how we want to set its properties.
98
99
00:09:10,580 --> 00:09:18,680
And through this, we're able to customize the appearance of these widgets to our liking. All that we have
99
100
00:09:18,680 --> 00:09:22,700
to do now, is to get our column to be centered.
100
101
00:09:23,270 --> 00:09:30,460
So do you still remember how to do that? See if you can challenge yourself to find that out from the
101
102
00:09:30,460 --> 00:09:37,630
column documentation. See if you can figure out how to center our content for our column.
102
103
00:09:41,320 --> 00:09:50,020
Let's head over to our column class. And you might already remember this, from our previous lessons on
103
104
00:09:50,020 --> 00:09:57,460
the column, but one of the most important things that you can set is the cross axis alignment and the
104
105
00:09:57,460 --> 00:10:04,360
main axis alignment. The main axis determines how the children should be placed along the main
105
106
00:10:04,360 --> 00:10:10,270
axis, which in the case of a column, is of course along this axis.
106
107
00:10:10,270 --> 00:10:13,460
So that is the one that we want to make centered.
107
108
00:10:13,540 --> 00:10:17,970
So let's find out where we created our column, and then right underneath it,
108
109
00:10:17,980 --> 00:10:23,740
we're going to add our main axis alignment, and we're going to change it to center.
109
110
00:10:24,310 --> 00:10:30,790
And now, all of our items will get pushed right into the middle, and it starts looking a lot more like
110
111
00:10:30,880 --> 00:10:39,210
a little business card. So now, the final thing that we need to add, is a little line between this section
111
112
00:10:39,330 --> 00:10:47,310
and this section to separate it. And to do that, we're going to add a sized box because this is a really
112
113
00:10:47,310 --> 00:10:55,380
easy way of adding something with a fixed height inside our column. And I'm gonna give it a height of
113
114
00:10:55,440 --> 00:11:04,200
just 20 points. And then, I'm gonna give it a child. And the child is gonna be a horizontal line.
114
115
00:11:04,200 --> 00:11:10,470
So in web design, you have something called the horizontal rule which creates a single horizontal line.
115
116
00:11:11,010 --> 00:11:18,390
But in Flutter, we have something called a divider. And the divider class simply puts a one pixel thick
116
117
00:11:18,450 --> 00:11:22,230
horizontal line, onto our screen.
117
118
00:11:22,230 --> 00:11:32,590
Let's add that as the child. And let's change its color to maybe a nice light teal color.
118
119
00:11:37,360 --> 00:11:42,340
And you can see that we now have this line going from edge to edge.
119
120
00:11:42,400 --> 00:11:46,850
Now what if we want it to be just a little bit shorter?
120
121
00:11:46,890 --> 00:11:55,080
Well, we can actually change the size of our sized box because at the moment, its width is as wide as
121
122
00:11:55,080 --> 00:11:56,150
the screen.
122
123
00:11:56,220 --> 00:12:01,040
What if we change the width, instead to 150 pixels.
123
124
00:12:01,110 --> 00:12:09,060
Now our line gets just a little bit shorter, and it's just enough to separate our top group and our bottom
124
125
00:12:09,060 --> 00:12:17,460
group. So in this module, we explored a number of widgets including layout widgets such as containers,
125
126
00:12:17,490 --> 00:12:27,560
columns and rows, but also customizable widgets such as a circle avatar or the card widget or list tile.
126
127
00:12:27,720 --> 00:12:33,810
And we looked at how we can use the documentation to see what properties of these widgets we can set
127
128
00:12:34,290 --> 00:12:37,500
and customize them to our liking.
128
129
00:12:37,500 --> 00:12:44,360
Finally we also learn about how to use custom fonts and icons to make our design come to life.
129
130
00:12:44,370 --> 00:12:51,300
So now it's truly your time to update this app to make it your own.
130
131
00:12:51,300 --> 00:12:53,570
So personalize it for yourself.
131
132
00:12:53,640 --> 00:13:00,030
Change it to have your details or your job description or whatever it is that you want to change about
132
133
00:13:00,030 --> 00:13:02,480
this. And once you're done,
133
134
00:13:02,480 --> 00:13:08,380
be sure to share it with the community and everybody else who's taking the course along with you,
134
135
00:13:08,570 --> 00:13:15,530
using the hashtBrew. And I look forward to seeing all of your amazing creations.
135
136
00:13:15,950 --> 00:13:17,930
So that's all for me for this module.
136
137
00:13:17,930 --> 00:13:18,970
I'll see you on the next one.
15987
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.