33
Basics of Dart
In this post, I will be going over the very basics of Dart. I will be covering things that are both unique to Dart (in some ways) and standard things that every programming language has. Let's get started!
To start things off, let's take a look at a simple hello world example as a classic introduction to any programming language :)
// 1
void main() {
// 2
print('Hello, World!');
}
// some examples of expressions
1 + 1
// some examples of statements
var a = 1;
print('Hello, World!');
The next important concept that every programming language has is variables. A variable is just something that you want to store in memory for usage later.
String firstVar = 'first variable';
print(firstVar);
- Cannot be keywords. Can find list of keywords here: https://dart.dev/guides/language/language-tour#keywords
- Can contain alphabets and numbers, but cannot have a number in the beginning.
- Cannot contain spaces or special characters except $ and _.
- I suggest not getting into habit of starting a variable name with $ or _. The reason will make more sense later.
- Prefer using camel casing for long variable names.
Another important feature in every programming langugage (or at least from the ones I know) is comments.
// this is a single line-comment
/*
* this is a multi-line comment
*/
That's a wrap for this intro to Dart. Next up is Dart Types!
If you have any question, leave a comment or reach out to me directly and I'll do my best to help you and / or revise my post for better clarity.
If you have any question, leave a comment or reach out to me directly and I'll do my best to help you and / or revise my post for better clarity.