-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2-variables.dart
48 lines (40 loc) · 1.04 KB
/
2-variables.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* statically typed language,
* also flexible and supports type inference
* with `var`, `const` and the `dynamic type`
* On web, types may not be 100% enforced at runtime.
*/
// Mutable Variables
int data = 3;
var otherData = 5;
// Immutable Variables with `final`
// We can set final variables' content at runtime
final notMutableObject = "final string";
final int otherImmutable = 5;
// We must set const content at compile time
const pi = 3.14;
playingWithTypes() {
// Core Data Types
String stringValue;
int integerValue;
double doubleValue;
bool booleanValue;
dynamic anything;
num aNumber;
// String Literals, double quotes or single quotes
print("Hello World");
// Multi-line literal strings
var multiline = """
sdfsdf
""";
print(multiline);
var price = 3;
var otherPrice = 5.2;
// Every string can have template expressions using $ or ${}
// expression result will be converted to string
var message = "The $price price is ${otherPrice * 1.1}";
print(message);
}
void main() {
playingWithTypes();
}