Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,170 --> 00:00:08,190
So what's up with TextAlign.center and EdgeInsets.all? These are certain Dart features, not Flutter
2
00:00:08,190 --> 00:00:11,360
specific and they're not exactly the same.
3
00:00:11,560 --> 00:00:17,950
This here is a special constructor, EdgeInsets has multiple constructors and you can see them here
4
00:00:17,950 --> 00:00:24,580
if you add a dot after the class type, so without parentheses, then you see all these constructors here.
5
00:00:24,730 --> 00:00:30,190
Now these features exist to allow you to create an object in different variants.
6
00:00:30,220 --> 00:00:36,250
Now it can always be nice to look into the raw source code to understand what's going on and you can
7
00:00:36,250 --> 00:00:42,940
always do that by holding command on MacOS or control on Windows and then you hover over the thing
8
00:00:42,940 --> 00:00:47,950
you want to learn more about and it now turns into a link which you can click and if you do click it,
9
00:00:47,980 --> 00:00:52,740
you're taken to the framework code. We see that enum
10
00:00:52,750 --> 00:00:57,910
I was talking about, you create it with the enum keyword here as you can see and we'll do that manually,
11
00:00:57,910 --> 00:01:02,350
later we'll create our own enums, for the moment let's basically ignore that, these are just different
12
00:01:02,440 --> 00:01:08,530
options we have for alignment here which are then picked up by Flutter once we assigned a value to align
13
00:01:08,530 --> 00:01:11,790
our text per the option we chose here.
14
00:01:11,860 --> 00:01:14,590
What's more helpful is diving into EdgeInsets here.
15
00:01:14,590 --> 00:01:20,380
So if we dive into this, we now see it's a class that extends EdgeInsetsGeometry, which is interesting
16
00:01:20,380 --> 00:01:23,770
because you might remember that if you hover over margin,
17
00:01:23,770 --> 00:01:26,650
this takes EdgeInsetsGeometry value,
18
00:01:26,650 --> 00:01:29,770
So it's good that EdgeInsets extends this,
19
00:01:29,770 --> 00:01:36,880
this means that if we instantiate EdgeInsets, we automatically get an object of type EdgeInsetsGeometry
20
00:01:37,210 --> 00:01:44,110
because if you extend, if you have a class that extends another class, that class that does extend always
21
00:01:44,230 --> 00:01:52,000
has its own type as well as the type of the class it did extend, that's also a default behavior of Dart.
22
00:01:52,060 --> 00:01:57,380
Now in here, we see that there are a couple of special constructors here,
23
00:01:57,400 --> 00:02:01,510
we repeat the class name, which always means it's an instructor
24
00:02:01,510 --> 00:02:10,810
but then instead of directly adding parentheses thereafter, we add dot some name and that is a Dart feature
25
00:02:10,810 --> 00:02:15,400
which allows you to define multiple constructors per class.
26
00:02:15,460 --> 00:02:21,040
Now without diving too much into the internals here, in the end that just means that each constructor
27
00:02:21,130 --> 00:02:28,180
creates a new instance of this class but with different configurations, with different settings and that
28
00:02:28,210 --> 00:02:35,260
all is just done to make it easy for you to create different EdgeInsets, which is basically a settings
29
00:02:35,260 --> 00:02:42,910
container setting up spaces. Setting up different EdgeInsets containers with different configurations
30
00:02:43,090 --> 00:02:50,470
with these utility functions here, with these utility constructors. If I go back to DartPad, we could
31
00:02:50,470 --> 00:02:55,070
have created that for person as well, we could have added our own constructor by adding the name and
32
00:02:55,070 --> 00:03:05,280
then dot and then any name of your choice, for example veryOld and in there, we could have accepted
33
00:03:05,280 --> 00:03:11,230
the name and then said that this constructor by default sets age equal to 60.
34
00:03:11,280 --> 00:03:15,480
So here, we can't set the age in the constructor, it's always set to 60 and
35
00:03:15,480 --> 00:03:17,050
we can only set the name.
36
00:03:17,130 --> 00:03:22,520
Now this would be a helpful constructor if we wanted to create a person, p3
37
00:03:22,710 --> 00:03:25,830
that always is 60 where we only want to set the name.
38
00:03:26,010 --> 00:03:30,510
So we could use the veryOld constructor and set this to Max again,
39
00:03:30,510 --> 00:03:39,830
so my name again and now if I print p3.name and I then also print p3.age, if I run this
40
00:03:39,840 --> 00:03:46,500
now, you will see that here we actually get Max and then 60 being printed and that is the output for
41
00:03:46,500 --> 00:03:48,330
our p3 object.
42
00:03:48,390 --> 00:03:54,960
So these special or these extra constructors are really just there to give you the same type of object
43
00:03:54,990 --> 00:04:02,730
you would get with the normal constructor but with some predefined settings, some different behaviour
44
00:04:03,210 --> 00:04:04,920
they run inside of the constructor.
5247
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.