Dart Programming Tutorial (1/3)
What is Dart 🎯 ?
In other words, if you have ever heard about Flutter framework, and you are willing to learn it, then dart is a must.
Dart is just a programming language, having syntax similar to JavaScript and developed by Google.
That's all you need to know right now.
Learning anything needs motivation. So, let us see
Why Learn Dart?
1. Dart is an open-source language and supported by Google. (that gives us a trust factor).
2. Dart is used Flutter (most important reason)
3. Dart is a robust and efficient language.
4. Dart is easy to learn and can be a good choice as your first programming language.
Where to Run Dart programs?
Unlike any other programming language, you don't need to install any software or IDE to run dart programs.
yes, that's all you need to write dart programs.
This is how your dartpad looks.
Okay, enough talk let's do some coding 😎
First Dart Program
Let's us decode it line by line :
void main()
1. This is a function.
2. A function is just like a machine, you give it some input material and it performs some operations on it and produces an output.
So, a function is just a block of code that may or may not accept input and may or may not produce an output.
3. We will learn Functions in detail later in this section. (Take a chill-pill if you don't get it now)
4. void main() is a special type of function which marks the entry of any dart program.
It is just like the Gate of your house, anything that has to enter your house enters from this gate.
5. main() function is called the driver of the program.
It is the point from which the compiler starts executing the code.
By the way, dart just like any other programming language is executed sequentially. So, first the first statement of the program is executed then second then third, and so on.
6. A task that has to be performed by a function is enclosed in a pair of braces { }
print('Hello World');
1. print(), is again a function
2. print(), performs the task of displaying data on the screen
3. print(data), can accept numbers, characters, or lists as data.
4. semicolon; at the end of the print statement is a must. a semicolon marks the end of any dart statement. (the statement is a line code which does something).
5. Here we are printing Hello World, Hello World is a set of characters which we call a String.
6. A String needs to be enclosed in a pair of single quotes ''
7. So if I want to print my name, print() statement would be like
print('Abhishek');
Comments
Post a Comment