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() { | |
| for (var i = 1; i <= 5; i++) { | |
| print('🎄' * i); | |
| } | |
| } | |
| // Output: | |
| // 🎄 | |
| // 🎄🎄 | |
| // 🎄🎄🎄 | |
| // 🎄🎄🎄🎄 |
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
| // Mock API class | |
| class CovidAPI { | |
| Future<int> getCases() => Future.value(1000); | |
| Future<int> getRecovered() => Future.value(100); | |
| Future<int> getDeaths() => Future.value(10); | |
| } |
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
| final api = CovidAPI(); | |
| final values = await Future.wait([ | |
| api.getCases(), | |
| api.getRecovered(), | |
| api.getDeaths(), | |
| ]); | |
| print(values); // [1000, 100, 10] |
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
| class PasswordValidator { | |
| bool call(String password) { | |
| return password.length > 10; | |
| } | |
| } |
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
| final validator = PasswordValidator(); | |
| //puede usarlo así: | |
| validator('test'); | |
| validator('test1234'); | |
| // no es necesario usarlo así: | |
| validator.call('not-so-frozen-arctic'); |
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
| class CustomDraggable extends StatelessWidget { | |
| const CustomDraggable({Key key, this.onDragCompleted}) : super(key: key); | |
| final VoidCallback? onDragCompleted; | |
| void _dragComplete() { | |
| // TODO: Implement me | |
| } | |
| @override | |
| Widget build(BuildContext context) {/*...*/} | |
| } |
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
| Future<void> _dragComplete() async { | |
| onDragCompleted?.call(); | |
| } |
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() { | |
| final sayHi = (name) => 'Hi, $name'; | |
| welcome(sayHi, 'Jaime'); | |
| } | |
| void welcome(String Function(String) greet, | |
| String name) { | |
| print(greet(name)); | |
| print('Bienvenido al curso'); | |
| } |
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
| int square(int value) { | |
| // solo un simple ejemplo | |
| // podría ser una función compleja con mucho código | |
| return value * value; | |
| } | |
| // Dada una lista de valores, podemos mapearlos para obtener los cuadrados: | |
| const values = [1, 2, 3]; | |
| values.map(square).toList(); |
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
| const restaurant = { | |
| 'name' : 'Pizza Mario', | |
| 'cuisine': 'Italian', | |
| if (addRatings) ...{ | |
| 'avgRating': 4.3, | |
| 'numRatings': 5, | |
| } | |
| }; |