Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,800 --> 00:00:06,380
Our app states, which it is now storing every single image inside this images list right here, so
2
00:00:06,380 --> 00:00:11,360
we're now going to figure out how we can build a list of widgets out of all the records that we're storing
3
00:00:11,360 --> 00:00:12,560
into our images list.
4
00:00:12,930 --> 00:00:16,309
Again, this is going to be an exercise in basic list building.
5
00:00:16,550 --> 00:00:21,320
And this is something that we're going to have to do in every application out there that builds a list
6
00:00:21,320 --> 00:00:22,280
at some point in time.
7
00:00:22,520 --> 00:00:25,480
And it turns out that's probably the vast majority of apps.
8
00:00:25,940 --> 00:00:28,550
So we're going to be building lists several times throughout this course.
9
00:00:28,550 --> 00:00:31,000
And right now will be the first taste that we'll get of it.
10
00:00:31,900 --> 00:00:38,320
Now, our app state, which it right now has a pretty good amount of code inside of it, and we're getting
11
00:00:38,320 --> 00:00:43,330
up to 40 lines, I personally like to keep these widgets as small and compact as possible.
12
00:00:43,690 --> 00:00:49,090
So although we could definitely add all this logic to create a list inside of our app state class right
13
00:00:49,090 --> 00:00:55,630
here, I think it might make a little bit more sense to create a new separate widget class that's going
14
00:00:55,630 --> 00:00:59,740
to take our list of images and render them out as a list on the screen.
15
00:01:01,500 --> 00:01:04,080
So to how is this new class that we're going to put together?
16
00:01:04,290 --> 00:01:09,980
I'm going to make another new directory inside of my SIRC folder inside of Sarsae.
17
00:01:10,030 --> 00:01:12,570
I'll make a new folder called Widgets.
18
00:01:13,470 --> 00:01:18,660
So the widgets directory right here over time might house all the different reusable widgets that I
19
00:01:18,660 --> 00:01:22,450
will create inside of my application, inside of the widgets directory.
20
00:01:22,500 --> 00:01:24,750
I'm going to make a new file and I'll call it.
21
00:01:24,750 --> 00:01:28,800
How about image underscore list dot dart.
22
00:01:29,160 --> 00:01:30,270
I think that's a reasonable name.
23
00:01:32,610 --> 00:01:37,140
Then inside this file, we're going to first start off with that import statement that I'm going to
24
00:01:37,140 --> 00:01:40,640
expect to see in just about every widget file I ever create.
25
00:01:41,070 --> 00:01:46,320
It's all, say, import packets, flutter material darts.
26
00:01:48,380 --> 00:01:53,810
Then right underneath that, we're almost definitely going to need to know some information about the
27
00:01:53,810 --> 00:01:58,910
image model that we've created inside of our application, the image list, which it is supposed to
28
00:01:58,910 --> 00:02:01,100
iterate over the list of all those images.
29
00:02:01,260 --> 00:02:06,840
So this file is definitely going to need to know about exactly what a image model type is.
30
00:02:07,370 --> 00:02:09,810
So we're going to import that file inside of here as well.
31
00:02:10,669 --> 00:02:15,200
So let's say import and then this time to import that file, we're going have to write out a little
32
00:02:15,200 --> 00:02:16,910
bit more complicated import statement.
33
00:02:17,460 --> 00:02:24,410
So I need to go up one directory into the Sarsae folder, then into models and then get the image model
34
00:02:24,410 --> 00:02:26,420
dot dart file to do so.
35
00:02:26,420 --> 00:02:28,960
I'm going to write out dot, dot, slash.
36
00:02:29,030 --> 00:02:32,000
So that goes up one directory into SIRC.
37
00:02:32,690 --> 00:02:38,660
Then I'm going to go into the models folder and then get the image model darte file Lexar.
38
00:02:39,930 --> 00:02:40,240
Ko.
39
00:02:41,790 --> 00:02:49,860
OK, so now we'll create the actual image list, which it is also a class image list extends and then,
40
00:02:50,190 --> 00:02:52,410
oh, a little bit of hesitation there.
41
00:02:52,890 --> 00:02:58,020
I want to think for a second, are we making a stateless widget or a state full widget?
42
00:02:58,710 --> 00:03:03,840
Well, let's go back and look at our diagram one more time to remind ourselves if I can find it.
43
00:03:05,000 --> 00:03:05,450
Here we go.
44
00:03:07,260 --> 00:03:12,480
So my question to you is whether or not you think this new widget that we're going to create is going
45
00:03:12,480 --> 00:03:15,540
to have any instance variables that are going to change.
46
00:03:16,590 --> 00:03:22,000
Is it going to have any instance variables that are going to be changed by the widget itself?
47
00:03:22,520 --> 00:03:24,830
That's definitely a very tricky question.
48
00:03:25,770 --> 00:03:32,010
The image list that we are creating is going to be given a list of image model instances and we're going
49
00:03:32,010 --> 00:03:38,070
to have to definitely somehow like save that list of images inside this widget so that we can refer
50
00:03:38,070 --> 00:03:42,590
back to that list later on when our build method gets called or whatever else we're trying to do.
51
00:03:43,350 --> 00:03:48,620
So I think that we are going to have to know about that list of images inside this widget.
52
00:03:49,050 --> 00:03:55,590
And I think that without a doubt, that list of images will change over time because we're going to
53
00:03:55,590 --> 00:03:58,840
be adding on no new images every time the user presses that button.
54
00:03:59,310 --> 00:04:01,580
However, this is the key part.
55
00:04:01,590 --> 00:04:08,190
However, it is the parent widget of the app state that is changing that data.
56
00:04:09,000 --> 00:04:10,860
So our image lists right here.
57
00:04:10,860 --> 00:04:12,750
It is going to have an instance variable.
58
00:04:13,140 --> 00:04:15,840
I kind of will expect that to change over time.
59
00:04:16,350 --> 00:04:19,260
But it's not the image list job to change it.
60
00:04:19,829 --> 00:04:25,110
So because the image list right here is not changing that variable, because it is not in charge of
61
00:04:25,110 --> 00:04:30,840
maintaining that list of images, we're going to make this a stateless widget.
62
00:04:31,470 --> 00:04:37,140
The image list is never going to try to change that list of images and it's never going to try to render
63
00:04:37,140 --> 00:04:37,730
itself.
64
00:04:38,100 --> 00:04:41,640
And so it's a prime candidate to be a stateless widget.
65
00:04:43,910 --> 00:04:48,660
OK, so then inside of here, we're going to eventually build out our list.
66
00:04:48,920 --> 00:04:54,050
First, let's take a quick break and we'll come back to the next section and take a look at some documentation
67
00:04:54,050 --> 00:04:55,270
on how we can build a list.
68
00:04:55,370 --> 00:04:56,800
So I'll see you in just a minute.
6970
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.