All language subtitles for 024 Creating a New Flutter Project from Scratch.en_US

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French Download
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,300 --> 00:00:06,510 All right. So now that we're finally done with setup and configuration, we're ready to get started with 2 00:00:06,510 --> 00:00:12,650 Flutter development and build our very first app. And that app is an app called I Am Rich. 3 00:00:12,780 --> 00:00:18,240 Now, if you haven't heard of the story, basically in the early days of the app store, when it was still 4 00:00:18,240 --> 00:00:25,160 very much the Wild Wild West of app development, a guy called Arman decided to create an app called I 5 00:00:25,160 --> 00:00:25,790 Am Rich. 6 00:00:25,860 --> 00:00:27,400 And it was a pretty clever idea. 7 00:00:27,930 --> 00:00:31,970 He decided that he was going to make an app that basically does absolutely nothing. 8 00:00:31,980 --> 00:00:40,980 It just shows a single icon of a red ruby on the screen. And he decide to price it at the maximum possible 9 00:00:40,980 --> 00:00:47,970 price at the App Store would allow, which was $999.99, and 10 00:00:48,060 --> 00:00:56,640 he pitched it as an art and lifestyle app, for people who are very rich to display to other people how 11 00:00:56,640 --> 00:00:57,820 rich they are. 12 00:00:57,870 --> 00:01:03,210 Alternatively, for people who are slightly silly to display to the world that they purchased an app that 13 00:01:03,210 --> 00:01:05,190 does nothing for $1,000. 14 00:01:05,190 --> 00:01:13,080 But either way, before the app got pulled by Apple, seven or eight people actually bought it, five of which 15 00:01:13,080 --> 00:01:17,970 were probably kids. Kids who probably got beaten up by their parents for paying an app that does nothing 16 00:01:17,970 --> 00:01:19,180 for $1,000. 17 00:01:19,500 --> 00:01:24,580 But this is a perfect app for us to get started with developing Flutter apps. 18 00:01:24,700 --> 00:01:28,720 It'll let us get used to the development environment and all the small buttons. 19 00:01:28,860 --> 00:01:33,420 And also see how exactly an actual Flutter app is built from scratch. 20 00:01:33,600 --> 00:01:37,770 So once you're ready, fire up Android Studio and let's get started. 21 00:01:37,770 --> 00:01:42,950 So once you're ready, go ahead and crack open Android Studio and select the option 22 00:01:42,960 --> 00:01:49,560 where we get to start a new Flutter project. And we're gonna select this first option to create a Flutter 23 00:01:49,650 --> 00:01:53,050 app and go ahead and click next. 24 00:01:53,130 --> 00:01:56,300 Now we get to name our project, and we're going to call it 25 00:01:56,340 --> 00:01:58,230 i_am_rich. 26 00:01:58,620 --> 00:02:04,110 So this should be lowercase, with a underscore between each of the words in your project name. 27 00:02:04,710 --> 00:02:07,870 And then we're going to leave all of the rest as it is. 28 00:02:07,950 --> 00:02:14,640 This part tells you where your project is going to be saved. By default usually get saved into a folder 29 00:02:14,670 --> 00:02:23,080 called Android Studio projects and you'll be able to find it if you search for Android Studio projects. 30 00:02:23,280 --> 00:02:26,670 And this is where your brand new app is gonna be created. 31 00:02:26,670 --> 00:02:33,720 Now that we've named our project, let's go ahead and click next and here, it expects us to type in a company 32 00:02:33,720 --> 00:02:34,960 domain. 33 00:02:34,980 --> 00:02:39,610 So for example our website is www.appbrewery.co 34 00:02:39,690 --> 00:02:44,100 So our company domain will be appbrewery.co 35 00:02:44,100 --> 00:02:50,490 Now, the reason why they want this is so that they can create a package name for your app, combining your 36 00:02:50,490 --> 00:02:57,180 company domain with the name of your project to create something that can identify this particular app 37 00:02:57,450 --> 00:02:59,690 uniquely, on the app stores. 38 00:02:59,700 --> 00:03:05,600 So they're hoping that nobody at appbrewery.co will make a duplicate app and try to upload it. 39 00:03:05,610 --> 00:03:10,410 Now what should you do if you don't have a website or a company domain? 40 00:03:10,410 --> 00:03:16,340 Well, you can simply just type in your full name and ended with a .com. 41 00:03:16,740 --> 00:03:23,790 And as long as nobody has the same name as you who's tried to develop an app called I am rich, then you 42 00:03:23,790 --> 00:03:27,240 should be okay. If you do have a website that you own, 43 00:03:27,240 --> 00:03:30,360 then of course, nobody else will own the website that you own. 44 00:03:30,360 --> 00:03:34,940 So it ensures that this is actually going to be unique. 45 00:03:34,950 --> 00:03:42,120 So now, let's go ahead and click finish, and Android Studio will create a brand new Flutter project for 46 00:03:42,120 --> 00:03:51,800 you and it'll set you up with some starting code. The starting code is created by the Flutter team, and 47 00:03:51,980 --> 00:03:56,060 all it does is it creates a simple counter app. 48 00:03:56,060 --> 00:04:01,580 Now in this case it's a counter app that is created using what's called a scaffold. 49 00:04:01,580 --> 00:04:07,250 And if you want to just quickly run it just to see what it looks like then go ahead and open up your 50 00:04:07,280 --> 00:04:11,270 Android emulator or your iOS simulator, and click Run. 51 00:04:16,030 --> 00:04:18,400 And once it's done, this is what you should see. 52 00:04:18,400 --> 00:04:25,890 It's a really simple application with a top bar with some text the middle and a button that you can press. 53 00:04:25,930 --> 00:04:28,890 Now this is not the app that we want to create. 54 00:04:28,900 --> 00:04:34,810 This is just the Flutter team showing you what you can do with scaffolds, and we're going to be building 55 00:04:34,870 --> 00:04:37,170 ours pretty much entirely from scratch. 56 00:04:37,300 --> 00:04:43,090 So we're gonna be creating a scaffold, and we're going to be using it to build our 'I am rich' app. But 57 00:04:43,450 --> 00:04:45,550 in order to understand what's going on, 58 00:04:45,550 --> 00:04:52,630 I'm actually going to delete everything that's currently inside the file, other than the top two lines. So 59 00:04:52,720 --> 00:04:55,600 everything up to pretty much line 12. 60 00:04:55,600 --> 00:05:02,620 So now we get a little error here, and you see it in Dart Analysis as well, where it says "MyApp isn't 61 00:05:02,620 --> 00:05:08,680 defined." Well that's because MyApp was actually the Flutter team's app, it was the counter app. So that 62 00:05:08,680 --> 00:05:11,150 doesn't really exist anymore because I just deleted it. 63 00:05:11,680 --> 00:05:20,440 So instead, the app that we're going to run is a blank MaterialApp, and this app will be something that 64 00:05:20,440 --> 00:05:29,080 conforms to the material design pattern. And material design is simply just a design style or a concept 65 00:05:29,350 --> 00:05:35,240 that was created by Google and a lot of startups and a lot of companies have adopted it for their 66 00:05:35,240 --> 00:05:42,970 websites and mobile apps. And by using Flutter, we get to tap into a lot of these material components, 67 00:05:43,270 --> 00:05:48,820 through the use of Flutter widgets. And we're going to see the power of these widgets and how we can 68 00:05:48,820 --> 00:05:56,820 incorporate these designs in, almost automatically, very very soon in this module. Let's get back to our 69 00:05:56,820 --> 00:06:02,940 Material App, and as you can see, we can start building up our tree of widgets. 70 00:06:03,180 --> 00:06:09,620 So inside the Material App, the most important thing you get to set is the home. 71 00:06:09,810 --> 00:06:12,750 And this is where everything starts. 72 00:06:12,750 --> 00:06:19,320 If we go ahead and say that in our Material App, in the home of the app, what we want to see is simply 73 00:06:19,380 --> 00:06:25,820 a text widget and this text widget just says hello world. Then, 74 00:06:25,830 --> 00:06:35,850 now, if we go ahead and actually run this app, then you can see our text show up inside our Material App. 75 00:06:36,270 --> 00:06:39,270 But at the moment, it doesn't look great right. 76 00:06:39,360 --> 00:06:46,850 It's just a black screen with some red text. But it does say what we wanted to say, which is hello world. 77 00:06:46,860 --> 00:06:51,950 We've really started building our widget tree, and it's a really simple one. 78 00:06:51,960 --> 00:06:59,400 It's only got two widgets. The first or the parent widget, is the Material App, and almost all of your 79 00:06:59,400 --> 00:07:04,200 Flutter apps will start off with this as the first widget. 80 00:07:04,260 --> 00:07:10,590 The next thing we're saying is that inside this Material App, the only thing that we want to show, is 81 00:07:10,650 --> 00:07:17,280 a text widget. And by default or text widgets get aligned to the top left corner. 82 00:07:17,490 --> 00:07:24,250 And this is why we're seeing it right up here because it's trying to be squarely in the top left corner. 83 00:07:24,270 --> 00:07:29,340 Now what if we wanted to make the text go into the center. 84 00:07:29,340 --> 00:07:36,810 Well as I said, Flutter apps are pretty much entirely built using widgets. And there's of course a widget 85 00:07:37,050 --> 00:07:39,300 for centering elements. 86 00:07:39,390 --> 00:07:48,240 So if instead of having text as the child of the Material App, it was inside a center widget. Then it 87 00:07:48,240 --> 00:07:52,670 will automatically be put it into the center of the screen. 88 00:07:52,950 --> 00:07:55,710 Our tree has gotten a little bit more complex. 89 00:07:55,740 --> 00:07:58,110 We've got three widgets now. Hurray. 90 00:07:58,320 --> 00:08:03,200 And the first widget or the parent is Material App. Inside the Material App, 91 00:08:03,210 --> 00:08:08,790 we have a center widget, which centers anything that it contains. 92 00:08:08,790 --> 00:08:11,940 And we've given it a text widget to contain. 93 00:08:11,940 --> 00:08:19,790 So the text automatically become centered. Let's go ahead and remove our text widget. 94 00:08:20,020 --> 00:08:25,450 So I'm just going to use COMMAND + X or CONTROL + X to cut it out, and we're just going to leave it here 95 00:08:25,450 --> 00:08:26,830 for the moment. 96 00:08:26,830 --> 00:08:34,390 And inside the Material App, instead of having the text widget, we're going to have a center widget and 97 00:08:34,390 --> 00:08:37,790 the center widget can have a child as well. 98 00:08:37,810 --> 00:08:40,550 So this is two levels deep now. 99 00:08:40,870 --> 00:08:45,720 And it's child is going to be a text widget. 100 00:08:45,790 --> 00:08:53,650 So now, when I run the app using the play button, you'll see that my hello world gets automatically moved 101 00:08:53,920 --> 00:08:56,410 into the center of the screen. 102 00:08:56,410 --> 00:09:01,690 And it's because it's the child of a center widget. 103 00:09:01,690 --> 00:09:07,120 What you'll come to notice while you're creating Flutter apps is that there are widgets that fulfill 104 00:09:07,180 --> 00:09:10,600 almost every role. Just as in a company, 105 00:09:10,630 --> 00:09:17,110 you might have accountants as well as salespeople as well as technical people. 106 00:09:17,110 --> 00:09:20,480 You also have widgets that perform a variety of roles. 107 00:09:20,560 --> 00:09:25,500 The text widget is responsible for displaying text and styling text. 108 00:09:25,600 --> 00:09:31,830 The center widget is responsible for laying out the screen, helping to put something right in the center. 109 00:09:32,560 --> 00:09:38,470 And the Material App is kind of like the grand daddy of all the widgets, because it usually sits at the 110 00:09:38,470 --> 00:09:43,470 top and everything that we build is pretty much a Material App. 111 00:09:43,570 --> 00:09:50,410 Now at the moment, our code is all on the same line and it's really hard to see which widget is inside 112 00:09:50,440 --> 00:09:51,720 which other one. 113 00:09:51,730 --> 00:09:54,750 So how can we make our lives easier. 114 00:09:54,760 --> 00:10:04,940 Well by installing Flutter and Dart packages, we automatically get access to a reformater called dartfmt. 115 00:10:05,200 --> 00:10:08,110 And this is really really helpful. 116 00:10:08,410 --> 00:10:17,440 But you have to help it to help you. The Flutter team advises that whenever you're creating a widget 117 00:10:17,920 --> 00:10:26,050 which usually involves these parentheses or these round brackets, after every one of these, just add a 118 00:10:26,050 --> 00:10:26,780 comma. 119 00:10:26,800 --> 00:10:34,900 So I'm gonna go ahead and add a comma to the end of all of my round brackets. And that means that when 120 00:10:34,900 --> 00:10:44,650 I hit save, or when I right click and click on reformat code with dartfmt, then it'll automatically turn 121 00:10:44,710 --> 00:10:51,770 my one line and very difficult to recognize code, into an indented structure. 122 00:10:51,790 --> 00:10:59,410 So now it's much easier to see that this text widget is inside this center widget which is inside this 123 00:10:59,410 --> 00:11:04,810 Material App and everything lies inside this thing called main. 124 00:11:04,810 --> 00:11:13,450 Now this thing called main is really important, because when our app is run, the starting file is this 125 00:11:13,450 --> 00:11:18,120 thing called main.dart which we're currently writing code inside. 126 00:11:18,190 --> 00:11:26,380 So it launches this app and it starts from the top. It looks for something called main. And then it looks 127 00:11:26,380 --> 00:11:29,070 to see what it should do. 128 00:11:29,110 --> 00:11:33,340 This is the starting point of all of our apps. 129 00:11:33,520 --> 00:11:42,370 Now in order to make our indented structure look even more organized, we can actually replace this so-called 130 00:11:42,460 --> 00:11:49,540 fat Arrow or what's a = and > with a set of curly braces. 131 00:11:49,540 --> 00:11:56,270 So we can change that into a curly brace at the beginning, and a curly brace right at the end. 132 00:11:56,980 --> 00:12:04,390 So this does exactly the same, as what it did before. But now, our code is reformatted so that we have 133 00:12:04,390 --> 00:12:12,700 this really nice and neat indentation. And at a glance, I can already tell what is inside what, which becomes 134 00:12:12,700 --> 00:12:19,220 really important as you're building out your app with more and more widgets inside each other. 135 00:12:19,430 --> 00:12:25,100 The final thing that I want to point out on this page is at the top here, you see this 136 00:12:25,130 --> 00:12:27,180 /.../ 137 00:12:27,410 --> 00:12:35,180 If you click on it, it will expand the content. And you can always collapse and expand things just by 138 00:12:35,180 --> 00:12:37,450 clicking in the margin over here. 139 00:12:37,460 --> 00:12:43,070 So if I want to collapse my entire Material App, then I can do that and make it appear like it's only 140 00:12:43,070 --> 00:12:44,660 taking up one line. 141 00:12:44,660 --> 00:12:51,470 Now this part is a message from the Flutter team, and it tells you what the original example code was 142 00:12:51,470 --> 00:12:58,490 trying to demonstrate and trying to show you. What's special about this is that it starts off with two 143 00:12:58,790 --> 00:13:07,220 // and in Dart, as with many other languages, this turns any text that comes after it, into 144 00:13:07,310 --> 00:13:08,660 a comment. 145 00:13:08,660 --> 00:13:14,270 Now comments are great, because they allow you to leave notes to yourself or to other people on your 146 00:13:14,270 --> 00:13:17,460 team, when you're working on the same code base. 147 00:13:17,480 --> 00:13:24,080 It means that I could tell my future self that, when I first wrote this code and I understood how it 148 00:13:24,080 --> 00:13:25,760 worked perfectly, 149 00:13:25,760 --> 00:13:33,770 what each part is meant to do. And while you're learning, it's a really good idea to leave notes for yourself 150 00:13:34,080 --> 00:13:39,570 through the use of these comments so that you can remember later on down the line, when you review your 151 00:13:39,570 --> 00:13:42,260 code, what each part is meant to do. 152 00:13:42,320 --> 00:13:44,040 So for example let me start this off. 153 00:13:44,100 --> 00:13:53,200 We can write, "The main function is the starting point for all our flutter apps." 154 00:13:53,440 --> 00:13:57,910 So that means the next time you come back to this and you look at this thing called main, you're like 155 00:13:57,940 --> 00:13:59,300 "Oh what does that do again?" 156 00:13:59,740 --> 00:14:05,470 Well, there's a really helpful comment from the past you, to try and help you to understand what it does. 157 00:14:05,590 --> 00:14:09,990 And you remember, "ah I know this is the starting point for all our apps." 158 00:14:10,030 --> 00:14:16,150 The first thing that happens when we launch our app, is it looks inside this main function to see what 159 00:14:16,150 --> 00:14:17,050 it should do. 160 00:14:17,170 --> 00:14:19,340 And it tells it that it should run an app. 161 00:14:19,510 --> 00:14:26,110 The app that it should run is a Material App, and the Material App will have a center widget which helps 162 00:14:26,110 --> 00:14:32,850 you to center this text widget on screen. And that's how we end up with something that looks like this. 163 00:14:33,130 --> 00:14:38,740 Once you're happy with this, I recommend just deleting it because we won't need it. 164 00:14:38,740 --> 00:14:44,710 The part of the code that it's referring to, we've already deleted long ago, and I recommend to start 165 00:14:44,770 --> 00:14:50,800 leaving notes for yourself in the way of these comments so that you understand, later on, when you come 166 00:14:50,800 --> 00:14:55,070 back to your code what everything is doing and how it all works. 167 00:14:55,150 --> 00:15:01,930 In this lesson, we've already started building a widget tree and through the use of these widgets, we've 168 00:15:01,930 --> 00:15:08,670 created a really simple app that just displays the word hello world on screen. 169 00:15:08,740 --> 00:15:14,590 Now in the coming lessons, we're gonna be building this out and making it a lot more fancy look more 170 00:15:14,590 --> 00:15:17,530 like the I Am Rich app that we're going to build. 171 00:15:17,830 --> 00:15:23,710 But this is the starting point for building any Flutter app, and when you're building your own apps, you 172 00:15:23,710 --> 00:15:29,770 now know how to go through the wizard and remove the starting code so that you can customize it to turn 173 00:15:29,770 --> 00:15:31,930 it into your own app. 18895

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.