Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,940 --> 00:00:05,980
In the last section, we finished up our custom widget of app, we're going to come back to this file
2
00:00:05,980 --> 00:00:10,210
in just a little bit and do a better review of exactly what we accomplished in here, complete with
3
00:00:10,210 --> 00:00:13,570
a couple of diagrams to give you a better idea of exactly what's going on here.
4
00:00:13,870 --> 00:00:16,329
But right now, I just want to get our application working.
5
00:00:16,910 --> 00:00:19,690
I'm not going to flip back over to my main dart file.
6
00:00:20,270 --> 00:00:26,500
So inside of this file, we want to import that new app widget that we just created and then pass that
7
00:00:26,500 --> 00:00:31,870
app widget off to the run app function, which the recall takes a widget and shows it on the screen
8
00:00:31,870 --> 00:00:32,860
of our mobile device.
9
00:00:33,680 --> 00:00:39,670
So in order to get access to that custom app widget we just created, we have to add an import statement
10
00:00:39,670 --> 00:00:41,070
to the main dart file.
11
00:00:41,980 --> 00:00:47,920
We've already spoken about import statements when we are importing files from an outside package, but
12
00:00:47,920 --> 00:00:53,890
this time around we are importing a file that is defined inside of our own local project.
13
00:00:54,830 --> 00:00:59,270
To do so, we're going to write out a slightly different import statement than what than the one we
14
00:00:59,270 --> 00:00:59,900
did before.
15
00:01:00,590 --> 00:01:05,000
Let's first start off by taking a look at a quick diagram to give you a better idea of how we're going
16
00:01:05,000 --> 00:01:05,990
to write this import.
17
00:01:07,420 --> 00:01:14,410
OK, so this right here is the complete story around imports, this covers the three different types
18
00:01:14,410 --> 00:01:17,620
of import statements that we're going to write inside of our flutter applications.
19
00:01:18,310 --> 00:01:24,490
It covers the case in which we are importing code from the standard library in which we are importing
20
00:01:24,520 --> 00:01:29,320
a file in our live directory to another file inside of our directory.
21
00:01:29,440 --> 00:01:35,110
So essentially importing a file that you and I wrote ourselves and then importing something into our
22
00:01:35,110 --> 00:01:38,950
live directory from a package that has been installed into our project.
23
00:01:39,520 --> 00:01:43,300
So let's first start with the one down here, because this is the one that we just took care of.
24
00:01:43,990 --> 00:01:50,320
So, again, if we want to import something in to our Leyb folder or into a file in our live folder
25
00:01:50,680 --> 00:01:53,500
from anything outside that live folder.
26
00:01:53,710 --> 00:01:56,230
So an example, this would be some outside package.
27
00:01:56,770 --> 00:02:04,030
Then we would write import the word package, a colon, the package name and then the name of the file
28
00:02:04,030 --> 00:02:05,380
that we want from that package.
29
00:02:05,740 --> 00:02:08,080
So, again, this is the one that we've already done.
30
00:02:09,240 --> 00:02:13,680
Now, let's go up to the very top, because this is another very easy import statement, if we want
31
00:02:13,680 --> 00:02:20,850
to import anything from the standard library and we just try to import the word dart, a colon, and
32
00:02:20,850 --> 00:02:26,240
then the name of the module from the standard library that we want to import into our current file,
33
00:02:27,030 --> 00:02:30,240
we're going to have to write one of these import these import statements very shortly.
34
00:02:30,360 --> 00:02:32,490
So we'll come back to these in just a moment.
35
00:02:33,330 --> 00:02:36,810
So what we're going to do right now falls into this second case.
36
00:02:37,410 --> 00:02:43,320
We are trying to import something from our live directory or in other words, a file in our live directory
37
00:02:43,320 --> 00:02:50,010
that you and I wrote into another file inside our live directory that you and I wrote to do.
38
00:02:50,010 --> 00:02:52,590
So all we write out is the word import.
39
00:02:53,740 --> 00:02:58,840
The path to that file, like the relative path to that file and then the name of the file that we are
40
00:02:58,840 --> 00:03:04,630
importing and so forth is import statements, right here are examples of how we would import a sibling
41
00:03:04,630 --> 00:03:05,070
file.
42
00:03:05,830 --> 00:03:07,660
Now that starts to get a little bit complicated.
43
00:03:07,660 --> 00:03:12,280
So let's just flip back over to our code editor and I'll show you how we do this import statement for
44
00:03:12,280 --> 00:03:13,750
our particular case right now.
45
00:03:15,700 --> 00:03:22,360
OK, so back over here, we are in a file inside of our live directory, the main file, and we want
46
00:03:22,360 --> 00:03:25,430
to import another file inside of our live directory.
47
00:03:25,810 --> 00:03:30,460
Yes, it's nested inside of SIRC, but ultimately the file is inside the Lib directory.
48
00:03:31,180 --> 00:03:33,700
So we're going to write out import.
49
00:03:34,620 --> 00:03:38,860
Then the path or the relative path to the fire that we're trying to impart.
50
00:03:39,210 --> 00:03:48,120
So I want to look into the SIRC directory and find the app dot dart file like so and that's it.
51
00:03:50,740 --> 00:03:52,510
So we're inside the main theater directory.
52
00:03:52,660 --> 00:03:56,080
We're going to go into Sarsae and find the dirt file.
53
00:03:57,730 --> 00:04:02,020
OK, so that's pretty much it, that's the second case right here, and we're going to see an example
54
00:04:02,020 --> 00:04:04,000
of this first case up here in just a moment.
55
00:04:04,000 --> 00:04:05,980
So we'll come back to this diagram at that point.
56
00:04:07,040 --> 00:04:08,600
All right, so now back over here.
57
00:04:09,830 --> 00:04:14,690
The last thing we have to do now that we are importing our custom app widget, we're going to make sure
58
00:04:14,690 --> 00:04:19,540
that our run app function right here attempts to show an instance of our app widget.
59
00:04:20,149 --> 00:04:24,980
So I'm going to remove this VA app because we don't really need to define our app ahead of time.
60
00:04:26,190 --> 00:04:33,570
And then into run app, I will pass app with a set of princes like so so again, this takes our app
61
00:04:33,570 --> 00:04:38,700
class, creates a new instance out of it, and then we pass that instance off to run app.
62
00:04:39,950 --> 00:04:41,300
All right, so let's save this file.
63
00:04:42,220 --> 00:04:43,630
I'll go back over to my terminal.
64
00:04:44,670 --> 00:04:50,970
I'm going to do a full reload with Schifter, and then I'm just going to expect to see the exact same
65
00:04:50,970 --> 00:04:52,260
content up here on the screen.
66
00:04:52,440 --> 00:04:57,210
At this point, there should be no changes except for the fact I think my button should probably go
67
00:04:57,210 --> 00:05:03,280
back to a plus down here because we just reverted that back to the icon ad and there we go.
68
00:05:03,600 --> 00:05:08,900
So there's my ad icon and my oops, my ad just successfully restarted.
69
00:05:09,420 --> 00:05:10,570
So this looks pretty good.
70
00:05:10,590 --> 00:05:15,260
We have now created our own custom widget to find inside of a separate file.
71
00:05:15,780 --> 00:05:20,010
We then import it back to the main dirt file and successfully showed it on the screen.
72
00:05:21,010 --> 00:05:25,270
So the steps we just went through was just a little confusing, so let's take a quick pause.
73
00:05:25,280 --> 00:05:29,200
We're going to come back to the next section and we're just going to look at a diagram or two that's
74
00:05:29,200 --> 00:05:31,710
going to model out the current state of our application.
75
00:05:32,020 --> 00:05:33,520
So I'll see you in just a second.
8011
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.