Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,450 --> 00:00:06,600
To wire these two things up and see something on the screen, in main,
2
00:00:06,650 --> 00:00:12,030
we need to execute some code which takes our widget here and draws it to the screen
3
00:00:12,890 --> 00:00:21,230
and for that, there is another function provided by material.dart and that is called runApp. Now
4
00:00:21,230 --> 00:00:26,750
runApp is a normal function but not written by us but written by the Flutter team and exposed in that
5
00:00:26,750 --> 00:00:27,680
material.dart file.
6
00:00:28,430 --> 00:00:34,790
So as you can probably tell, importing that material.dart file unlocks a lot of core features which we
7
00:00:34,790 --> 00:00:40,690
need to build an app. Now runApp does what the name suggests, so it basically runs our Flutter app once
8
00:00:40,690 --> 00:00:47,480
the Android app booted up or the iOS app, whatever it is and that simply means it now tries to take our widget
9
00:00:47,480 --> 00:00:52,020
tree and draw something onto the screen that's based on that tree,
10
00:00:52,040 --> 00:00:56,060
so here it would draw that text here onto the screen. For that
11
00:00:56,060 --> 00:01:01,880
however, we need to tell runApp what our core widget is and that's our MyApp widget of course.
12
00:01:01,880 --> 00:01:06,500
So here we pass MyApp and we execute this like a function by adding parentheses,
13
00:01:06,500 --> 00:01:07,730
that is important,
14
00:01:07,730 --> 00:01:11,810
don't forget these parentheses, otherwise you would use it as a type
15
00:01:11,810 --> 00:01:17,420
but this does not need a type but a concrete object and you instantiate an object based on a class
16
00:01:17,660 --> 00:01:19,470
by adding parentheses.
17
00:01:19,520 --> 00:01:23,710
That's also what we did here when we created our persons, right.
18
00:01:26,840 --> 00:01:33,490
Now runApp does just that, it runs the app, takes our widgets and runs that, to be precise what it does
19
00:01:33,490 --> 00:01:38,440
with our widget is of course it creates that, we're calling the constructor after all, so such a widget
20
00:01:38,500 --> 00:01:43,450
object is getting created and then runApp does take this object which we passed to it in the end here, which
21
00:01:43,450 --> 00:01:49,390
we pass as an argument to runApp, we pass the finished object, the finished widget object here after
22
00:01:49,390 --> 00:01:54,910
all by calling the constructor. runApp takes that and calls the build method for us, that's in the end
23
00:01:55,150 --> 00:01:59,610
what it does and that's how build gets triggered here for the first time and how this
24
00:01:59,710 --> 00:02:06,220
construction of our app then continues and how something gets rendered onto the screen and therefore
25
00:02:06,220 --> 00:02:12,520
if we now save that file and we go to debug and again start this without debugging, we should now be
26
00:02:12,520 --> 00:02:20,410
able to bring this back onto the emulator and see a very basic and ugly application there, which somewhere
27
00:02:20,570 --> 00:02:21,960
outputs
28
00:02:21,970 --> 00:02:23,540
hello.
29
00:02:23,620 --> 00:02:29,080
And as you can also tell therefore is that we basically only care about the user interface and what we
30
00:02:29,080 --> 00:02:37,120
see there and that's a cool thing. We don't have to care about rendering individual pixels or managing
31
00:02:37,330 --> 00:02:43,380
the lifecycle of the app, starting it up and listening to events on the home screen of our Android device,
32
00:02:43,390 --> 00:02:44,770
we do none of that,
33
00:02:44,860 --> 00:02:48,630
what we do here is we control what ends up on the screen.
34
00:02:49,450 --> 00:02:54,580
So now this is getting built into an apk here for my Android emulator,
35
00:02:54,580 --> 00:02:57,350
once it's done, it launches up and we see this. Now
36
00:02:57,400 --> 00:02:59,070
this is the expected result,
37
00:02:59,080 --> 00:03:01,010
we haven't defined any styling,
38
00:03:01,090 --> 00:03:06,530
we haven't defined anything that will lead to something more beautiful being rendered but we see hello
39
00:03:06,540 --> 00:03:07,320
here.
40
00:03:07,660 --> 00:03:13,840
And that therefore proves that this basic code works, that we created our own widget class which is a
41
00:03:13,840 --> 00:03:19,450
normal class with some extra features provided by stateless widget and that this was accepted by the
42
00:03:19,450 --> 00:03:23,170
main function to run our app with the help of runApp.
4729
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.