1. Dart - Basics
Run Dart code in VSCODE with:
dart dartfile.dart
Basic function format:
void main() {
print("HELLO");
}
// OR exclude void. Void just mean function returns no values.
main() {
print("HELLO");
}
Calling Functions:
function();
Variables can have types:
int = int numbers.
double = float numbers.
String = strings.
bool = booleans.
List = like array. [1,2,3]
Map = like array. { "x":5, "y":6}
null = nothing
dynamic = a variable that can change its type
Math Basics:
variable++
or
variable = variable + 1
variable--
or
variable = variable - 1
Referencing variables:
$variable
this references to the variable.
${variable - 10}
adjusting the variable that is referenced. But doesnt change it.
Escaping characters inside strings:
print("This is a semicolon \:");
use a backlash to escape characters.
Escaping a whole string:
r"HELLO "@%"@%"@"%@%@""
putting "r" in front of a string escapes everything inside.
Operator Types:
== equal to
!= not equal to
>
<
>=
<=
! not:
!variable means not variable
!(variable > 10) expression
Comments
Post a Comment