This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This are the different data types in data language | |
void main() { | |
String a = 'Hello'; | |
int b = 123; | |
dynamic c = 'Hello'; | |
c = 123; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This is how to generate a rondom number in Dart | |
// The integer will be from 1 - 6 since i added (+1) | |
import 'dart:math'; | |
void main() { | |
int randomNumber = Random().nextInt(6) + 1; | |
print(randomNumber); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
List<String> myList = [ | |
'Charles', | |
'James', | |
'Bella', | |
'Jack', | |
]; | |
//print(myList[3]); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Challenge: Without changing the main() function, can you make this code work and get the result printed in the console? | |
void main() { | |
int step1Result = add(n1: 5, n2: 9); | |
print(step1Result); | |
int step2Result = multiply(step1Result, 5); | |
double finalResult = step2Result / 3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If and Else statement in dart | |
// Symbols used: | |
// == is equal to | |
// ! is not equal to | |
// > is greater than | |
// < is less than | |
// >= is greater or equal to | |
// && AND | |
// || OR | |
// ! NOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main(){ | |
Human jenny = Human(startingHeight: 15); | |
jenny.talk('Mommy'); | |
print(jenny.height); | |
// Human james = Human(20); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// INHERITANCE AND POLYMORPHISM | |
void main(){ | |
//Car myCar = Car(); | |
// myCar.drive(); | |
// print (myCar.numberOfSeats); | |
// ElectricCar myNewCar = ElectricCar (); | |
// print(myNewCar.numberOfSeats); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// All about class construtor and how to use this. | |
void main(){ | |
Human jenny = Human(height: 15, weight: 3.4); | |
//jenny.talk('Mommy'); | |
print(jenny.height); | |
print(jenny.weight); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//How to use enum | |
void main () { | |
Car myCar = Car(carStyle: CarType.convertable); | |
print(myCar); | |
} | |
class Car { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//How to use ternary operators | |
void main () { | |
int myAge = 21; | |
bool canIDrink = myAge >= 21 ? true : false; | |
print(canIDrink); | |
} |
OlderNewer