Created with <3 with dartpad.dev.
Created
May 31, 2023 07:56
-
-
Save hesptech/355f26341fa985c2fd050a4adab442ca to your computer and use it in GitHub Desktop.
mellow-rainbow-6529
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 myNameVar = 'Fer'; | |
String myNameString = 'Fer'; | |
final myNameFinal = 'Fer'; | |
late final myNameLate = null; | |
final bool varBool = true; | |
dynamic myNameDynamic = 'hola'; | |
myNameDynamic = 1; | |
myNameDynamic = [1,2,3,4]; | |
myNameDynamic = {1,2,3,4}; | |
myNameDynamic = { 1: 1, 2: 2}; | |
myNameDynamic = null; | |
myNameDynamic = () => true; | |
final Map pokemon = { | |
'name': 'name', | |
'int': 1, | |
'bool': true, | |
'nameList': <String>[], | |
'nameMap': <dynamic, dynamic>{ | |
'num': 1, | |
1: 's3', | |
}, | |
1: 's1', | |
2: 's2', | |
'sprites': { | |
1: 'front', | |
3: 'back', | |
varBool: false, | |
}, | |
'a': myNameVar, | |
'b': myNameString, | |
'c': myNameFinal, | |
'd': myNameLate, | |
'e': varBool, | |
'f': myNameDynamic, | |
}; | |
//print('hola $myNameString ${myNameString.toUpperCase()}'); | |
//print({ 1 + 1}); | |
//print(pokemon['nameMap']['num']); | |
print( 'front: ${ pokemon['sprites'][varBool] }'); | |
int addTwoNumber(int a, int b) => a + b ; | |
print(addTwoNumber(10, 10)); | |
int functionName( int a, [ int? b, int c = 0, ] ) { | |
b??= 0; | |
return a + b + c ; | |
} | |
functionName(4,4,4); | |
final windPlant = WindPlant( initialEnergy: 100); | |
print(windPlant); | |
} | |
// | |
enum PlantType {nuclear,wind,water} | |
abstract class EnergyPlant { | |
double energyLeft; | |
PlantType type; | |
EnergyPlant({ | |
required this.energyLeft, | |
required this.type, | |
}); | |
void consumeEnergy(double amount); | |
} | |
class WindPlant extends EnergyPlant { | |
WindPlant({ required double initialEnergy }) | |
: super(energyLeft: initialEnergy, type: PlantType.wind); | |
void consumeEnergy(double amount) { | |
energyLeft -= amount; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment