Last active
July 7, 2020 14:30
-
-
Save Davids89/bd2a7550f3575cec780f15ae99b49b25 to your computer and use it in GitHub Desktop.
This file contains hidden or 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() { | |
// Listas | |
print('==========================================='); | |
print('-------- Lists --------'); | |
print('==========================================='); | |
List<String> nssFlutter = ['NSS', 'Agile', 'Scrum']; | |
nssFlutter.add('Miwo'); | |
print(nssFlutter); | |
print(nssFlutter.length); | |
List<int> intList = new List.generate(3, (int index) => index * index); | |
print(intList); | |
nssFlutter.where((item) => item.contains('NSS')).forEach(print); | |
List<String> newList = [...nssFlutter, 'Flutter']; | |
print(newList); | |
// Funciones | |
print('==========================================='); | |
print('-------- Functions --------'); | |
print('==========================================='); | |
printGreeting(); | |
bool itIsChristmas = isItChristmas(); | |
print('Is it Christmas? $itIsChristmas'); | |
namedParamsFunction(surname: 'Luque', name: 'David'); | |
// Estructuras de control | |
print('==========================================='); | |
print('-------- Control structures --------'); | |
print('==========================================='); | |
if (true) { | |
print('It is true'); | |
} | |
nssFlutter.forEach((item) => print(item)); | |
for (String item in nssFlutter) { | |
print('Element $item'); | |
} | |
// Clases | |
print('==========================================='); | |
print('-------- Classes --------'); | |
print('==========================================='); | |
Employee employee = new Employee(); | |
employee.name = 'Julian'; | |
print(employee.name); | |
employee.skills(); | |
// Async - await | |
printWithDelay('Async response'); | |
// Gestión de errores | |
print('==========================================='); | |
print('-------- Try catch --------'); | |
print('==========================================='); | |
String myString = 'abc'; | |
try { | |
double doubleValue = double.parse(myString); | |
print(doubleValue + 5); | |
} catch (e) { | |
print(e); | |
} | |
} | |
void printGreeting() { | |
print('Hello'); | |
} | |
bool isItChristmas() { | |
DateTime today = new DateTime.now(); | |
return today.day == 25 && today.month == 12; | |
} | |
void namedParamsFunction({String name, String surname}) { | |
print('Hello $name $surname'); | |
} | |
Future<void> printWithDelay(String message) async { | |
const oneSecond = Duration(seconds: 3); | |
// Future representa la respuesta de una llamada asíncrona | |
await Future.delayed(oneSecond); | |
print('==========================================='); | |
print('-------- Async await --------'); | |
print('==========================================='); | |
print(message); | |
} | |
class Person { | |
String name; // Las clases tienen getter y setter por defecto | |
} | |
// Esto es un mixin, lo podemos usar en las clases para compartir funciones comunes entre clases | |
class Coder { | |
void skills() { | |
print('I am good in JS LOL'); | |
} | |
} | |
class Employee extends Person with Coder { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment