Transcript from the "Dart Basics" Lesson
>> It's time to go and see some Dart code, okay, before actually getting into Flutter. So I'm going to get out of the slide for a minute and I'm going to use VS Code to open a folder that you have in the assets. So remember that we have in firtman.github.io/intro-flutter, we have a lesson, the first one, where you can download the workshop assets.
[00:00:27] So in that ZIP file, you have a couple of images that we will use later. And also there is a folder with the name dart101, okay? So these are the basics of Dart. I want you to go. In fact, if you go to the next lesson here, it will just tell you to download the slides.
[00:00:44] And next one, so the third lesson will actually tell you again to download the assets and open in Visual Studio or Android Studio, up to you, so be ready. I want you to open the folder dart101, okay? So I will use Visual Studio. It's the same if you wanna use Android Studio.
[00:01:04] So I'm going to open a folder. And I'm going to look into my, The Assets > dart101. So I'm going to open that folder. In that folder, what we have is a couple of files, Dart files. And by the way, you can see at this point the extension of Dart files, it's .dart.
[00:01:27] And here we can actually start playing with some Dart code and see errors in the compiler. Well, the first news that I have for you, I know that when I'm saying this, a lot of people will feel a little sad about this, but yeah, you'll get used to that.
[00:03:43] Print will actually print to the console. Have in mind that on different platform, the console means different things. Like on iOS and Android, there is an output console, but it's not actually the screen. On the web, the console is the browser's console. And if you're doing desktop applications, well, the console is the output console.
[00:04:04] The term, you can see that in the output console where you're running your app, okay, but the place is different on different platforms. So as you can see here, I have, what is this? So you can guess what it is because it has parentheses. It's actually a function.
[00:04:22] Why do I have a function here? Because I cannot have global code, like a global leaf. That's not possible in Dart. Everything must be in a class or in a function. So that's why here, to actually show you some code that will not giving us any errors, I need to put that into a function.
[00:05:01] So for example, variable names. Constant names, we will get into that in a minute what's a constant. And function names, they use CamelCase. So we start with lowercase, and then we move up to CamelCase on our letter such as the M in message, okay? Everything is public in the package.
[00:05:21] What's a package? In Dart, everything that we're doing in a project is by default a package, and we can have more than one package. So a package actually is kind of a folder, okay? And when you wanna use something from other package, you need to import the package.
[00:05:36] This is similar to packages in Java or the namespaces in .NET, or even PHP, okay? So if you have used those languages, you probably know the idea of a package or a namespace. It's just a way to group, to contain different, let's say, objects that can be, for example, classes or functions or global variable.
[00:06:02] So everything is public by default, but if you prefix your name with underscore, it becomes private automatically. So from other packages, even if you're importing the package, you cannot use or see that variable or function or class, okay? So it does not use visibility prefixes, such as protected, private, or public.
[00:07:39] So here, this is more like the for each or for of of other languages.