Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,960 --> 00:00:07,110
In the last section, we added in a border that is displayed around our child of the network image.
2
00:00:07,560 --> 00:00:11,760
It's the last thing we have to really do here is make sure that underneath the network image, we see
3
00:00:11,760 --> 00:00:13,750
the title of the given image.
4
00:00:14,640 --> 00:00:20,160
Now, before we dive in on doing exactly that, there's one thing I want to point out about our current
5
00:00:20,370 --> 00:00:21,600
item builder right here.
6
00:00:22,230 --> 00:00:24,990
The item builder is definitely starting to grow in size.
7
00:00:25,110 --> 00:00:27,840
There's a lot of very nested code inside of here.
8
00:00:28,080 --> 00:00:33,120
And even as you've been following along in the last couple of videos, you might have made some accidental
9
00:00:33,120 --> 00:00:38,550
typo, you know, left out a comma or something inside of here, all because this heavily nested code
10
00:00:38,550 --> 00:00:40,280
is kind of tough to read.
11
00:00:40,950 --> 00:00:46,050
So I think that rather than continuing to stack up more of this widget logic directly inside of our
12
00:00:46,050 --> 00:00:53,250
item builder function, we should extract some of this to a helper method defined on our image list
13
00:00:53,250 --> 00:00:53,850
class.
14
00:00:54,570 --> 00:00:55,850
So let's try doing that right now.
15
00:00:57,350 --> 00:01:02,960
Underneath my build method, I'm going to create a new method that I'm just going to arbitrarily call
16
00:01:03,440 --> 00:01:08,790
build image, totally making that name up the name build right here.
17
00:01:08,850 --> 00:01:11,180
This is a very importantly named method.
18
00:01:11,360 --> 00:01:16,010
We have to have a method called build on all of our state lists and stateful widgets.
19
00:01:16,250 --> 00:01:20,570
This thing gets called automatically to determine what this widget is supposed to be showing on the
20
00:01:20,570 --> 00:01:20,960
screen.
21
00:01:21,410 --> 00:01:24,080
But the name of build image right here, not special.
22
00:01:24,080 --> 00:01:25,840
I just made it up off the top of my head.
23
00:01:27,110 --> 00:01:33,920
When we call build image, we're going to expect to construct a container where some type of widget,
24
00:01:34,280 --> 00:01:37,700
so I'm going to mark the return type of build image as being widget.
25
00:01:38,680 --> 00:01:44,320
And then when we call build image, presumably we're going to call this one time every time the item
26
00:01:44,320 --> 00:01:49,690
builder runs, so I'm going to assume that we're going to pass in the image model that we're trying
27
00:01:49,690 --> 00:01:50,920
to construct a widget for.
28
00:01:51,370 --> 00:01:56,590
So I'm going to say we're going to receive an image model instance that we'll just call image.
29
00:01:59,210 --> 00:02:01,340
So now inside my item builder.
30
00:02:02,240 --> 00:02:03,980
I'm going to find my container.
31
00:02:04,920 --> 00:02:11,610
And I'm going to find the closing parentheses for the container right there, please, please double
32
00:02:11,610 --> 00:02:17,220
check, make sure you've got the correct closing parentheses and then going to cut all that.
33
00:02:19,040 --> 00:02:21,770
Inside of my building, which I'm going to return.
34
00:02:23,600 --> 00:02:25,040
That container like so.
35
00:02:27,540 --> 00:02:31,860
Then inside the item builder function, I'm going to make sure that I call build image.
36
00:02:32,810 --> 00:02:37,430
And I'm going to pass in images at index like so.
37
00:02:38,060 --> 00:02:42,050
So now we are passing in a single image to the build image method.
38
00:02:42,950 --> 00:02:48,020
And then the last thing we have to do inside of build image, we still have that logic right here that's
39
00:02:48,020 --> 00:02:49,910
trying to look at our list of images.
40
00:02:50,090 --> 00:02:51,510
We don't want to do that anymore.
41
00:02:51,560 --> 00:02:54,710
We now want to reference the image that is being passed into this method.
42
00:02:56,030 --> 00:03:00,560
So I'm going to replace all that with image that you URL like, so.
43
00:03:01,660 --> 00:03:02,680
But I'll save the file.
44
00:03:03,730 --> 00:03:06,710
And I'm going to make sure that I don't see any errors inside of here.
45
00:03:07,120 --> 00:03:08,140
I think it looks good to me.
46
00:03:09,320 --> 00:03:14,780
So now, by extracting all that logic out of our item builder, the item builder is much easier to read,
47
00:03:14,780 --> 00:03:16,040
far more straightforward.
48
00:03:16,490 --> 00:03:22,910
And we now have a single build image method that is responsible for just showing one single image by
49
00:03:22,910 --> 00:03:23,360
itself.
50
00:03:24,300 --> 00:03:30,030
OK, so good improvement, but we're still not done yet when we call build image, we're trying to show
51
00:03:30,030 --> 00:03:34,840
the entire widget that shows that image with the title underneath it.
52
00:03:35,250 --> 00:03:37,380
So essentially, this thing right here.
53
00:03:37,380 --> 00:03:37,680
Right.
54
00:03:39,520 --> 00:03:43,960
So at this point, we've got the image showing up, we've got the border, but now we need to get the
55
00:03:43,960 --> 00:03:45,430
title in there as well.
56
00:03:46,030 --> 00:03:48,670
So right underneath the image, I want to see the title appear.
57
00:03:49,770 --> 00:03:54,570
Well, if we flip back over here, we're currently showing the container and we had said that to show
58
00:03:54,570 --> 00:03:59,130
something inside the container, we assign it to the containers child property.
59
00:03:59,940 --> 00:04:04,300
But if you look at child right here, well, that definitely sounds like a single widget.
60
00:04:04,890 --> 00:04:10,380
So when we show a container, it expects to receive a single widget that is going to be displayed inside
61
00:04:10,380 --> 00:04:10,680
of it.
62
00:04:10,980 --> 00:04:15,170
But we're now saying that we want to show both the image and the image title.
63
00:04:16,019 --> 00:04:22,410
So to get both those in there, we're going to wrap the image right here and the text widget that we
64
00:04:22,410 --> 00:04:26,450
need to create with another kind of layout widget.
65
00:04:27,090 --> 00:04:31,260
Let's look at some documentation really quickly, and I think you'll kind of get a better idea of what
66
00:04:31,260 --> 00:04:31,980
I'm talking about.
67
00:04:33,200 --> 00:04:40,310
So I'm going to pull up the widget catalog, remember, this is at Fledermaus Widgets and then inside
68
00:04:40,310 --> 00:04:43,220
of here I'm going to find the section named Layout right here.
69
00:04:48,470 --> 00:04:49,220
OK, here we go.
70
00:04:49,550 --> 00:04:53,750
So at the very top, you'll notice that we have some called single child layout widgets.
71
00:04:53,900 --> 00:04:59,450
So just as you would expect, this means that there is exactly one child allowed to be placed inside
72
00:04:59,450 --> 00:05:00,260
of each of these.
73
00:05:00,620 --> 00:05:02,380
We just made use of the container.
74
00:05:03,170 --> 00:05:07,360
We could also made use of padding center and maybe a couple others inside of here.
75
00:05:07,370 --> 00:05:11,640
So all these will only take a single widget and show one widget inside of it.
76
00:05:12,080 --> 00:05:17,390
So we need something that can contain multiple widgets together if we scroll down a little bit more.
77
00:05:18,330 --> 00:05:25,310
We'll find a section marked as multiuse child labor widgets, so this is what you and I really want,
78
00:05:25,560 --> 00:05:28,500
we want to try to show multiple widgets together.
79
00:05:29,580 --> 00:05:35,820
In particular, we want to make sure that ours are showing kind of one on top of each other, so laid
80
00:05:35,820 --> 00:05:37,200
out in a sort of column.
81
00:05:37,980 --> 00:05:42,060
And as you might guess, that's the exact purpose of this column, which is right here.
82
00:05:42,720 --> 00:05:48,810
So we can create a column widget that's going to take a list of childs and it's going to try to show
83
00:05:48,840 --> 00:05:51,840
each of those children in a vertical fashion inside of it.
84
00:05:52,440 --> 00:05:55,590
Now, if you want to, you could definitely look up the documentation on this.
85
00:05:58,360 --> 00:06:04,240
So it's going to take a list of children and show them all inside of it, and we could certainly look
86
00:06:04,240 --> 00:06:05,800
at the documentation right here.
87
00:06:06,080 --> 00:06:07,800
So we're going to create a column widget.
88
00:06:08,140 --> 00:06:12,790
We're going to provide a children property and then pass in a list of all the different widgets that
89
00:06:12,790 --> 00:06:13,720
we want to show in the column.
90
00:06:14,320 --> 00:06:17,710
Now, I think I've repeated that phrase like four times the last couple of seconds.
91
00:06:17,710 --> 00:06:19,960
So I think you get the idea of where we're going here.
92
00:06:20,290 --> 00:06:21,750
Let's go down to the constructor.
93
00:06:22,030 --> 00:06:23,200
Yeah, we make a column.
94
00:06:23,200 --> 00:06:26,790
We pass in our children as a list of widgets.
95
00:06:26,800 --> 00:06:27,640
That's pretty much it.
96
00:06:27,670 --> 00:06:28,960
So let's just do that right now.
97
00:06:31,090 --> 00:06:36,760
So rather than showing a single child of the network image, I'm going to remove the network image and
98
00:06:36,760 --> 00:06:39,340
I will replace it with a column.
99
00:06:41,690 --> 00:06:43,710
Now, we are not breaking the rules here.
100
00:06:44,030 --> 00:06:49,000
The container expects to receive one single child, and that's what we're passing to it now.
101
00:06:49,010 --> 00:06:54,560
We're passing a single column widget, but the column itself can contain multiple children inside of
102
00:06:54,560 --> 00:06:54,790
it.
103
00:06:55,100 --> 00:07:00,530
So that's how we're going to show multiple children inside of a so-called single child widget.
104
00:07:01,490 --> 00:07:10,250
So on the column, I'm going to add a children's prop., this is going to be a list, a list of widgets.
105
00:07:12,260 --> 00:07:19,280
Just to kind of annotate this thing correctly, I'm going to add on and say this is not list, but widget
106
00:07:19,280 --> 00:07:24,530
like so so that just means to say that we are creating a literal list that is going to contain nothing
107
00:07:24,530 --> 00:07:31,160
but widget type elements with most of the as with most of these type requirements, we don't actually
108
00:07:31,160 --> 00:07:35,270
have to like mark the thing as being of type widget or containing widgets.
109
00:07:35,270 --> 00:07:37,280
But, you know, it's a nice thing to do.
110
00:07:38,380 --> 00:07:44,350
So then inside of here, we can show our image and we'll write that again, it's image dot, network
111
00:07:44,710 --> 00:07:45,640
image, dot URL.
112
00:07:46,450 --> 00:07:52,750
And then second thing we're going to pass in here is a text widget that's going to display the title
113
00:07:52,750 --> 00:07:54,520
Property of our image model.
114
00:07:54,940 --> 00:07:56,710
Don't forget our image model.
115
00:07:56,980 --> 00:07:57,750
Here it is right here.
116
00:07:57,880 --> 00:07:59,590
It has that title property.
117
00:08:02,200 --> 00:08:08,080
So I'll make my text widget and inside there also image dot title and I'll make sure I get a comma at
118
00:08:08,080 --> 00:08:10,090
the end so that this line does not collapse.
119
00:08:10,900 --> 00:08:16,260
OK, so let's save that and we will do our refresh and see how we're doing.
120
00:08:17,220 --> 00:08:21,100
Now, before we actually look at this on the screen, there's one quick thing I want to mention here.
121
00:08:21,510 --> 00:08:25,060
Notice how we are showing this list of children inside the column.
122
00:08:25,560 --> 00:08:29,370
So at present, we're going to show the image and the text right underneath it.
123
00:08:29,760 --> 00:08:35,880
But we don't have anything inside of here right now to provide any type of spacing between our text
124
00:08:35,880 --> 00:08:36,510
in the image.
125
00:08:36,780 --> 00:08:41,220
So I kind of expect that we might see the text in the image, kind of like sandwiched up against each
126
00:08:41,220 --> 00:08:42,659
other a little bit too closely.
127
00:08:42,809 --> 00:08:44,159
But we'll see what happens.
128
00:08:45,060 --> 00:08:45,410
All right.
129
00:08:45,420 --> 00:08:47,030
I'm going to make sure that my reload kicked in.
130
00:08:47,040 --> 00:08:47,460
It did.
131
00:08:48,900 --> 00:08:55,680
So I'll add in a couple of images here, and I see fantastic, I get the title on there and as I add
132
00:08:55,680 --> 00:08:58,260
each additional image, I see the title appear.
133
00:09:00,150 --> 00:09:00,630
Awesome.
134
00:09:01,170 --> 00:09:06,750
OK, so that definitely is good, but like I just mentioned, that title is really sandwiched up against
135
00:09:06,750 --> 00:09:07,160
the thing.
136
00:09:07,170 --> 00:09:12,300
So I would like to put in just a little bit of margin or kind of padding on the top of that text just
137
00:09:12,300 --> 00:09:13,470
to separate the two a little bit.
138
00:09:14,040 --> 00:09:16,830
So let's take a quick pause and we'll take care of that in the next section.
13484
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.