Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,120 --> 00:00:05,980
In the last section, we added an important statement to our main dirt file and we had a brief discussion
2
00:00:05,980 --> 00:00:07,310
of what it's doing for us.
3
00:00:07,840 --> 00:00:11,190
We're not going to continue on to step two where we define our main function.
4
00:00:11,650 --> 00:00:16,720
So inside of here, I'm going to write out our main function, absolutely identical to how we wrote
5
00:00:16,720 --> 00:00:19,090
it out previously back over in Dart Pad.
6
00:00:19,720 --> 00:00:26,110
So I'm going to write out Void Main, a set of parentheses, and then my curly braces like so.
7
00:00:27,340 --> 00:00:32,380
Now, remember, this means that the name of the function is main and the void word right here means
8
00:00:32,380 --> 00:00:34,690
that we are returning nothing from this function.
9
00:00:36,370 --> 00:00:41,890
Now, steps three and four are going to be done inside of our main function, so I'm going to take both
10
00:00:41,890 --> 00:00:46,060
those comments and I'm going to paste them inside the main function like so.
11
00:00:47,390 --> 00:00:48,380
OK, it looks better.
12
00:00:49,770 --> 00:00:55,500
OK, so now inside of our main function, we're going to move directly on to step number three, so
13
00:00:55,500 --> 00:00:59,640
we need to create a text widget in order to show some text on the screen.
14
00:01:00,860 --> 00:01:05,420
To do this, I'm going to first write out a new variable that I will call simply app.
15
00:01:06,600 --> 00:01:12,900
And then inci or assigning to this, I'm going to create a brand new instance of a widget and I'm going
16
00:01:12,900 --> 00:01:19,470
to assign it to that variable, so I'm going to say material app is the name of the widget that I'm
17
00:01:19,470 --> 00:01:24,660
trying to create and then I'm going to pass it exactly one named parameter.
18
00:01:25,670 --> 00:01:28,580
So I'm going to write out a named parameter of home.
19
00:01:29,590 --> 00:01:33,520
And I'm going to assign to that name parameter a text widget.
20
00:01:34,630 --> 00:01:38,980
And to the text widget, I'm going to pass in the text that I ultimately want to show on the screen
21
00:01:38,980 --> 00:01:40,060
of my mobile device.
22
00:01:40,540 --> 00:01:43,450
So for me, I'm just going to say hi there like so.
23
00:01:45,860 --> 00:01:51,050
OK, so before we talk too much about what a material gap is or what text is or what this home thing
24
00:01:51,050 --> 00:01:53,690
is right here, there's one quick thing I want to tell you about.
25
00:01:53,690 --> 00:01:59,230
And this is something that is going to just haunt your days for as long as your building flutter applications.
26
00:02:00,050 --> 00:02:04,820
So if you have a code that looks identical to mine right here, I want you to save the file.
27
00:02:05,570 --> 00:02:08,120
Now, when you say the file, you might see something like that happen.
28
00:02:08,120 --> 00:02:10,699
You might see your code automatically collapse.
29
00:02:11,470 --> 00:02:15,830
So when we are working on flutter projects, if you're using visual studio code.
30
00:02:16,950 --> 00:02:21,580
Visual Studio Code is going to try to reformat your code every single time you save the file.
31
00:02:22,260 --> 00:02:25,850
Sometimes it's going to collapse your code to what you see right here.
32
00:02:25,860 --> 00:02:29,130
It's going to collapse it to be in as few lines as possible.
33
00:02:29,580 --> 00:02:34,740
But very often when we're building flutter applications, we want everything to be indented or we want
34
00:02:34,740 --> 00:02:38,970
to have a little bit of vertical structure so that we can more easily read our code.
35
00:02:39,690 --> 00:02:43,060
However, if you just save the file, it's always going to collapse itself.
36
00:02:43,500 --> 00:02:50,190
So in order to keep our code in this more vertical fashion, which is much easier to read, we're going
37
00:02:50,190 --> 00:02:56,750
to put a comma at the end of that line, the comma right here, make sure that this line does not collapse.
38
00:02:56,790 --> 00:03:00,150
So if I now save the file, it does not collapse anymore.
39
00:03:01,260 --> 00:03:05,100
Now, this might seem like a very small distinction right now, but over time, we're going to end up
40
00:03:05,100 --> 00:03:07,740
with some very heavily nested function calls.
41
00:03:08,130 --> 00:03:13,490
And you're going to want to make sure that those stay on separate lines so that it maintains its legibility.
42
00:03:14,040 --> 00:03:18,960
So in practice, I'm going to be adding on commas to the end of many lines of code that we put together.
43
00:03:19,230 --> 00:03:23,340
And I'll do my best to point them out just to make sure that you get a better idea of how they work.
44
00:03:24,330 --> 00:03:29,610
OK, so now a little bit more onto what's going on with the code, with these three lines of code right
45
00:03:29,610 --> 00:03:36,750
here, we are creating an instance of a dart class or what we call a widget that creates a material
46
00:03:36,750 --> 00:03:37,620
app widget.
47
00:03:38,010 --> 00:03:43,080
A material app widget is kind of like a very core level widget of our application.
48
00:03:43,770 --> 00:03:48,630
When we create a material app, it automatically sets up a lot of functionality inside of our application
49
00:03:48,630 --> 00:03:53,660
for us, such as the ability to navigate between different screens inside of our application.
50
00:03:54,420 --> 00:04:00,780
So it is somewhat common to see the one of the very core or widgets of your application be a material
51
00:04:00,780 --> 00:04:05,700
app because it sets up a lot of very default functionality that many different apps need out of the
52
00:04:05,700 --> 00:04:06,200
box.
53
00:04:07,960 --> 00:04:14,080
When we create the material app, we pass in a named parameter of home, the name parameter of home
54
00:04:14,080 --> 00:04:19,450
is used as the default route or the default widget to show on the screen when the application first
55
00:04:19,450 --> 00:04:19,990
starts up.
56
00:04:20,470 --> 00:04:26,590
So home right here, you can think of as many, like home screen or home widget is the first thing that's
57
00:04:26,590 --> 00:04:29,140
going to show up when our application first puts up.
58
00:04:30,300 --> 00:04:35,940
Then to the home parameter, we are assigning a text widget, a text, which it does exactly what you
59
00:04:35,940 --> 00:04:40,290
might think it does, it gets some text to show up on the screen, and that's pretty much it.
60
00:04:41,450 --> 00:04:45,050
OK, so that's this line of code right here, let's again take a very quick pause.
61
00:04:45,090 --> 00:04:49,190
We're going to come back to the next section and we're going to take that widget we just created and
62
00:04:49,190 --> 00:04:50,870
assigned to this variable right here.
63
00:04:51,050 --> 00:04:53,810
And we're going to get it to show up on the screen of our mobile device.
64
00:04:54,210 --> 00:04:56,140
So a quick break and I'll see you in just a minute.
7158
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.