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
abstract class Fruit { | |
factory Fruit(Fruits type){ | |
switch(type){ | |
case Fruits.Apple: | |
return Apple(); | |
case Fruits.Banana: | |
return Banana(); | |
default: | |
return null; |
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() { | |
print(ppap()); | |
} | |
class fruit { | |
var pineapple = '1'; | |
} | |
class tool { |
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
class Price { | |
int _coke=550,pepsi=450,cider=400; | |
int tax=50; | |
int get coke => _coke; | |
int get cola => (_coke+tax) + (pepsi+tax); | |
int get mix => (pepsi+tax) + (cider+tax); | |
int get all => (_coke+tax) + (pepsi+tax) + (cider+tax); | |
set coke(value) => _coke = value; |
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
class Car { | |
String name; | |
int gold; | |
int zeroToHundred; | |
Car({this.name, this.gold=124000, this.zeroToHundred}); | |
Car.sale(String name) : this(name:name, gold:117800, zeroToHundred:20); | |
@override | |
toString(){ |
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(){ | |
print('${sum1(1,2)}'); | |
print('${sum2(3,4)}'); | |
var list = [0,1,2,3,4].map((n) => n*n); | |
print(list); | |
} | |
int sum1(a, b){ | |
return a+b; |
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
class Car { | |
int gold; | |
int zeroToHundred; | |
int color; | |
Car({this.gold=124000, this.zeroToHundred, this.color}); | |
@override | |
toString(){ | |
return 'gold:$gold, zth:$zeroToHundred, color:$color'; |
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
class Car { | |
int gold; | |
int zeroToHundred; | |
int color; | |
Car(this.gold, this.zeroToHundred, this.color); | |
@override | |
toString(){ | |
return 'gold:$gold, zth:$zeroToHundred, color:$color'; |
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(){ | |
func1(100,200); | |
func2(v3:'hi'); | |
func3(123); | |
func3(123,456); | |
} | |
//optional var | |
void func1(var v1, v2){ | |
print('$v1, $v2'); |
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() { | |
var str1 = 'string1'; | |
var str2 = "string2"; | |
var str3 = 'str'+'ing3'; | |
var str4 = '$str1 is good'; | |
var str5 = '${5+3} is 8'; | |
var str6 = '${str1=='string1'?str2:str3} ~~'; | |
print('$str1'); | |
print('$str2'); |
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() { | |
final List<String> languages = []; | |
const List<String> companies = []; | |
languages.add('dart'); | |
/* | |
// compile error | |
companies.add('Github'); | |
languages = ['c']; |