Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,250 --> 00:00:05,210
In the last section, we wrote out four comments to guide us through the process of getting some content
2
00:00:05,210 --> 00:00:09,830
to show on the screen of our device in the section, we're going to tackle step number one, which is
3
00:00:09,830 --> 00:00:15,260
to import some code into our project so that we can actually work with our mobile device and get some
4
00:00:15,260 --> 00:00:16,140
content to show up.
5
00:00:16,850 --> 00:00:21,350
So before we write any code for this, I want to tell you a little bit more about how import statements
6
00:00:21,350 --> 00:00:21,710
work.
7
00:00:22,640 --> 00:00:24,260
All right, so quick diagram right here.
8
00:00:25,120 --> 00:00:31,420
OK, so in the very, very center of this diagram is our application, and right now our entire application
9
00:00:31,420 --> 00:00:34,120
consists of just the main file.
10
00:00:35,070 --> 00:00:41,250
Outside of our application, we have access to a ton of different code, so we have access to the entire
11
00:00:41,430 --> 00:00:45,780
darte standard library, which we took a little bit of a glance at the documentation for.
12
00:00:46,260 --> 00:00:51,990
And we also have the entire flutter standard library as well, which includes a lot of default widgets
13
00:00:51,990 --> 00:00:58,260
and things to help us build out mobile applications in order to get access to any of this code inside
14
00:00:58,260 --> 00:01:04,650
of our application, we have to first import it into our project or more specifically, import it into
15
00:01:04,650 --> 00:01:06,300
the file that we're working on.
16
00:01:07,200 --> 00:01:14,190
So if I want to say import a file from the Flutter Standard Library into my main file, I have to write
17
00:01:14,190 --> 00:01:21,330
out an import statement that tries to specifically go into the flutter standard library package, find
18
00:01:21,330 --> 00:01:27,300
some module inside of here, and then specifically add that module to my main file.
19
00:01:27,810 --> 00:01:30,390
Now, there's some very specific syntax around this.
20
00:01:30,600 --> 00:01:32,810
So let's look back over to our code editor.
21
00:01:33,120 --> 00:01:38,760
We're going to add our import statement and then we'll talk about how that syntax works.
22
00:01:39,660 --> 00:01:44,220
All right, so underneath this first comment, I'm going to write out imports and then going to put
23
00:01:44,220 --> 00:01:50,340
a set of single quotes, I'll say package Colin Flutter.
24
00:01:51,630 --> 00:01:55,410
Flash material, dot dart like so.
25
00:01:56,550 --> 00:02:02,880
OK, so that's our first import statement now before we talk about the exact syntax of this import statement,
26
00:02:03,240 --> 00:02:09,120
I want to let you know one very important thing here in Darte, there are three different types of import
27
00:02:09,120 --> 00:02:09,750
statements.
28
00:02:10,880 --> 00:02:15,470
The syntax around the import state import statement is going to change slightly depending upon where
29
00:02:15,470 --> 00:02:16,910
we are importing code from.
30
00:02:17,450 --> 00:02:22,700
So what you're seeing right here is how we write an import statement to import code from a third party
31
00:02:22,700 --> 00:02:23,360
package.
32
00:02:24,110 --> 00:02:29,720
If we're writing an import statement to import code from the standard library or to import code from
33
00:02:29,720 --> 00:02:35,090
a file that you and I have written inside of our project directory, then this syntax is going to change
34
00:02:35,090 --> 00:02:35,870
just a little bit.
35
00:02:36,470 --> 00:02:38,240
So this is one form of syntax.
36
00:02:38,240 --> 00:02:41,240
And very shortly we'll see those other two forms as well.
37
00:02:41,990 --> 00:02:45,890
OK, so now let's break down the syntax right here and talk about what's going on.
38
00:02:47,460 --> 00:02:48,740
All right, here we go.
39
00:02:50,090 --> 00:02:52,860
So here's that entire line of code broken down step by step.
40
00:02:53,540 --> 00:02:56,690
So the first word, I think you get a good sense of what's going on there.
41
00:02:56,850 --> 00:02:58,100
It's an import keyword.
42
00:02:58,100 --> 00:02:58,970
It's telling darte.
43
00:02:58,970 --> 00:03:01,820
We want to import some other file into this one.
44
00:03:02,720 --> 00:03:06,120
Then inside of that string is where things start to get really interesting.
45
00:03:06,650 --> 00:03:09,440
So the first word is package and then a colon.
46
00:03:10,100 --> 00:03:16,190
The word package specifically tells darte that we're trying to import code from a third party library
47
00:03:16,370 --> 00:03:18,500
that has been installed into our project.
48
00:03:19,190 --> 00:03:24,440
If we are importing code from the standard library or from a file that you and I wrote, then we're
49
00:03:24,440 --> 00:03:25,820
not going to have this word there.
50
00:03:25,850 --> 00:03:29,360
But we'll talk more about those import statements later on when we actually make use of them.
51
00:03:30,420 --> 00:03:35,700
After we write out package and then our colon, we then place the name of the library that we want to
52
00:03:35,700 --> 00:03:37,040
import code from.
53
00:03:37,440 --> 00:03:41,130
So in this case, we are trying to import some code from the flutter library.
54
00:03:42,160 --> 00:03:47,650
We then place a slash and then the name of the file that we're trying to import, so in this case we're
55
00:03:47,650 --> 00:03:52,340
trying to import the material file from the flutter library.
56
00:03:52,960 --> 00:03:56,080
Now, this last part right here might seem a little bit scary.
57
00:03:56,170 --> 00:04:01,540
You might be thinking, well, Stephen, how will I know what file I want to import from this library?
58
00:04:01,960 --> 00:04:03,190
And for that, don't sweat it.
59
00:04:03,520 --> 00:04:07,750
The documentation for the flutter for me, for the library that you're using is always going to tell
60
00:04:07,750 --> 00:04:12,230
you more or less exactly what file you want to import into your project.
61
00:04:12,610 --> 00:04:17,260
So in general, if you read the documentation, you're going to have a good idea of exactly what file
62
00:04:17,260 --> 00:04:18,220
you're trying to import.
63
00:04:19,200 --> 00:04:21,540
OK, so that's what's going on with this line of code right here.
64
00:04:21,959 --> 00:04:28,230
So now that we've imported this file into our project, which has some helpers to get the content on
65
00:04:28,230 --> 00:04:32,850
the screen, we'll continue in the next section where we'll define our main function and then continue
66
00:04:32,850 --> 00:04:34,050
on with the rest of our steps.
67
00:04:34,320 --> 00:04:36,300
So quick break and I'll see you in just a minute.
6877
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.