Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,160 --> 00:00:06,410
In the last section, we applied some marchin around the edge of our container widget, now that we've
2
00:00:06,410 --> 00:00:10,210
got some margin on there, we're also going to make sure that we get some padding as well.
3
00:00:10,700 --> 00:00:15,350
Remember, padding is the spacing that shows up inside at the border.
4
00:00:15,650 --> 00:00:20,600
But between the border and the actual widget that gets shown inside the container, it's all the padding
5
00:00:20,600 --> 00:00:26,000
does is making sure is make sure that there's some kind of standoff between the interior widget and
6
00:00:26,000 --> 00:00:26,930
the border itself.
7
00:00:27,260 --> 00:00:31,520
Otherwise, the border would touch everything inside of the container and it definitely wouldn't look
8
00:00:31,520 --> 00:00:32,080
that nice.
9
00:00:32,840 --> 00:00:36,550
So to add in some padding, we can go back to our container class.
10
00:00:37,040 --> 00:00:40,160
I will again find my constructor function right here.
11
00:00:40,940 --> 00:00:47,210
And you'll notice that just like we have a margin that accepts some edge in thing, we can also provide
12
00:00:47,210 --> 00:00:48,850
a padding property as well.
13
00:00:49,700 --> 00:00:54,170
So to add some padding into our container, I'll find my container widget right here.
14
00:00:54,770 --> 00:01:01,910
I'm going to add in a name, property of padding, and I will also give it an identical edge in sets.
15
00:01:02,510 --> 00:01:04,310
So I'll say edge insets.
16
00:01:04,819 --> 00:01:07,910
I want to add some padding on all sides of this container.
17
00:01:07,940 --> 00:01:13,730
So I'm going to use the all constructor and I'm going to give it a double of twenty, which again indicates
18
00:01:13,730 --> 00:01:16,250
that we want to have 20 pixels of spacing.
19
00:01:17,450 --> 00:01:22,010
OK, so we could definitely test this out inside the emulator, but I'm sure it's going to work just
20
00:01:22,010 --> 00:01:22,340
fine.
21
00:01:23,450 --> 00:01:27,830
If we tested it right now, it would really just look like there was additional padding or some additional
22
00:01:27,830 --> 00:01:29,360
margin around the container.
23
00:01:30,960 --> 00:01:36,840
The padding is not really going to be relevant until we actually get a border around this thing as well,
24
00:01:36,930 --> 00:01:42,060
because that border is going to give us some visual distinction between the padding spacing and the
25
00:01:42,060 --> 00:01:42,970
margin spacing.
26
00:01:43,440 --> 00:01:45,390
So let's start working on the border right now.
27
00:01:47,160 --> 00:01:53,670
So to add in the border, it's going to be just a little bit more complicated, not in terms of like
28
00:01:53,670 --> 00:01:59,310
theory or anything like that, the border is just more complicated because it's a bunch more of these
29
00:01:59,310 --> 00:02:03,440
like fancy class names you have to look out the documentation for, that's all.
30
00:02:04,260 --> 00:02:07,090
So to actually apply a border to the container.
31
00:02:07,440 --> 00:02:13,690
You'll notice that there's not any like border property inside of here to get a border on the container.
32
00:02:13,710 --> 00:02:16,380
We make use of this decoration property right here.
33
00:02:17,040 --> 00:02:21,380
The decoration property is used to apply some type of styling to our container.
34
00:02:21,750 --> 00:02:23,480
So that might take the form of a border.
35
00:02:23,520 --> 00:02:26,790
It might take the form of maybe some background color.
36
00:02:28,660 --> 00:02:33,370
To get a border show up, we need to assign something to this decoration property and it has to be of
37
00:02:33,370 --> 00:02:34,600
type decoration.
38
00:02:35,250 --> 00:02:38,610
So we'll go look at the documentation for decoration right here.
39
00:02:39,160 --> 00:02:44,740
Now, when we look at the decoration class, we can scroll down to the constructor, as usual, but
40
00:02:44,740 --> 00:02:48,490
you'll notice that it says right here, abstract const constructor.
41
00:02:49,130 --> 00:02:52,930
We'll talk a little bit more about what a abstract constructor is later on.
42
00:02:53,170 --> 00:02:58,540
But right now, all we really need to understand is that we don't use this decoration class directly
43
00:02:59,110 --> 00:03:01,870
instead to apply some decoration to a container.
44
00:03:02,200 --> 00:03:06,270
We instead use this box decoration thing that's listed right here.
45
00:03:06,760 --> 00:03:12,400
If you don't see the link for that, we can always do a search for box decoration as well.
46
00:03:15,430 --> 00:03:19,630
OK, so the box decoration class, again, let's go look at our constructor.
47
00:03:22,250 --> 00:03:28,730
Here's the constructor so we can assign to this thing a color, a image, presumably a background image,
48
00:03:28,730 --> 00:03:31,460
we can get some shadow on there, all this different stuff.
49
00:03:31,460 --> 00:03:37,790
But most importantly, we can assign a border property and you'll notice that even this border property
50
00:03:37,790 --> 00:03:40,450
right here is its own like separate object.
51
00:03:40,580 --> 00:03:44,590
So this is what I meant when I said doing the border was a little bit more complicated.
52
00:03:44,810 --> 00:03:47,480
It's not like theoretically more complicated.
53
00:03:47,480 --> 00:03:52,520
It's just this kind of vague mix or this big jumble of different classes that you have to be aware of.
54
00:03:53,120 --> 00:03:57,200
I know that right now you're probably looking at all these classes I'm clicking through and thinking
55
00:03:57,200 --> 00:04:00,270
like, how in the world am I ever going to remember this?
56
00:04:00,920 --> 00:04:02,770
Honestly, don't worry.
57
00:04:02,870 --> 00:04:07,520
As long as you've got one code snippet to reference, which is what we're doing right now, you're going
58
00:04:07,520 --> 00:04:11,510
to apply the same thing every time to apply a border to an object.
59
00:04:11,780 --> 00:04:18,050
So I know this jumble of classes looks nasty, but you just see the code one time and then you go back
60
00:04:18,050 --> 00:04:19,190
and reference that code again.
61
00:04:19,190 --> 00:04:19,850
In the future.
62
00:04:19,850 --> 00:04:20,660
We need a border.
63
00:04:20,779 --> 00:04:21,329
That's it.
64
00:04:22,040 --> 00:04:24,400
So let's let's kind of cut to the chase here.
65
00:04:24,800 --> 00:04:26,300
We know that our container.
66
00:04:27,300 --> 00:04:35,520
Is going to take a decoration property and the decoration must be a box decoration class.
67
00:04:38,850 --> 00:04:46,080
Then to the box declaration, we can provide a border property and now the last piece we haven't quite
68
00:04:46,080 --> 00:04:48,660
spoken about is how we actually get a border created.
69
00:04:49,030 --> 00:04:53,730
So again, unfortunately, we can't just say like one pixelate grey or something like that.
70
00:04:53,940 --> 00:04:56,040
We have to actually provide a widget right here.
71
00:04:56,500 --> 00:05:00,390
So to get a border, we're going to do border dot all.
72
00:05:01,080 --> 00:05:01,670
Now, that dot.
73
00:05:01,680 --> 00:05:02,040
All right.
74
00:05:02,040 --> 00:05:05,220
Here is the exact same thing as EJ INSETs.
75
00:05:05,220 --> 00:05:09,480
All all means that we want to apply a border on all sides of this thing.
76
00:05:09,510 --> 00:05:13,170
So on all sides, I want to apply an equal border.
77
00:05:15,900 --> 00:05:21,240
And then to this all constructor function, we're going to pass the color of the border that we want
78
00:05:21,240 --> 00:05:27,030
to use so we can pass in a color and then to specify the color again, unfortunately, we don't just
79
00:05:27,030 --> 00:05:28,320
say like gray or something.
80
00:05:28,530 --> 00:05:31,170
We actually have to specify a distinct color.
81
00:05:31,690 --> 00:05:37,530
So I'm going to say colors, which is a reference to an object that has a bunch of color codes assigned
82
00:05:37,530 --> 00:05:37,890
to it.
83
00:05:38,490 --> 00:05:42,420
And I'm going to pick out arbitrarily the color gray like so.
84
00:05:43,340 --> 00:05:47,600
All right, so I know I just went through this code right here kind of quickly, but again, my point
85
00:05:47,600 --> 00:05:52,130
here is that you don't have to memorize all this stuff when you need to do a border.
86
00:05:52,130 --> 00:05:54,500
Just come back and look at the sample code.
87
00:05:54,740 --> 00:05:59,330
Honestly, I don't know many people who are going to memorize every little character in here.
88
00:05:59,860 --> 00:06:04,580
Everyone is probably going to reference back on their notes or previous project and say, oh, yeah,
89
00:06:04,580 --> 00:06:05,500
that's how I do border.
90
00:06:06,080 --> 00:06:07,730
That's how I apply a border to a container.
91
00:06:08,830 --> 00:06:14,170
OK, so enough of that, let's save this thing, I'm going to make sure I get a comma at the end of
92
00:06:14,170 --> 00:06:20,040
this line so my code doesn't collapse and it will flip back over and test this out.
93
00:06:20,950 --> 00:06:25,030
Now, as usual, I know I got these longer appre start times.
94
00:06:25,030 --> 00:06:25,930
I apologize for that.
95
00:06:25,930 --> 00:06:32,290
It's because I'm recording video at the same time that I'm running an emulator and the compiler right
96
00:06:32,290 --> 00:06:37,690
here and that played a lot of demand for the resources on my laptop unfortunately.
97
00:06:38,720 --> 00:06:40,410
But it'll be just a second or two.
98
00:06:40,460 --> 00:06:40,910
There we go.
99
00:06:42,020 --> 00:06:44,300
So now we can add an image.
100
00:06:45,760 --> 00:06:51,610
And we get our nice looking border around the outside and now you can really see the difference between
101
00:06:51,610 --> 00:06:53,570
the margin and the padding start to come into play.
102
00:06:54,160 --> 00:06:57,140
So the margin is everything outside at the border.
103
00:06:57,850 --> 00:07:03,280
We then have the border and then we've got the 20 pixels of spacing inside that represents the padding.
104
00:07:03,860 --> 00:07:09,690
So now I can click again and again and all of our images start to appear awesome.
105
00:07:10,360 --> 00:07:14,320
So I think the last thing we have to do is make sure that we also get our title around this thing as
106
00:07:14,320 --> 00:07:14,590
well.
107
00:07:14,860 --> 00:07:17,560
So let's take a quick pause and take care of that in the next section.
10680
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.