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 functions = require('firebase-functions'); | |
| const cors = require('cors')({ origin: '*' }); | |
| const { Client, Webhook, resources } = require('coinbase-commerce-node'); | |
| const coinbaseSecret = 'your-api-key'; | |
| const signingSecret = 'your-webhook-secret'; | |
| Client.init(coinbaseSecret); | |
| const { Charge } = resources; |
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
| Stream.fromIterable([1, 2, 3]); | |
| Stream.value(10); | |
| Stream.empty(); | |
| Stream.error(Exception('ups! algo salio mal')); | |
| Stream.fromFuture(Future.delayed(Duration(seconds: 1), () => 42)); | |
| Stream.periodic(Duration(seconds: 1), (index) => index); |
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> printWeather() async { | |
| try { | |
| final api = WeatherApiClient(); | |
| final weather = await api.getWeather('London'); | |
| print(weather); | |
| } on SocketException catch (_) { | |
| print('No se pudieron recuperar los datos. Comprueba tu conexión'); | |
| } on WeatherApiException catch (e) { | |
| print(e.message); | |
| } catch (e, st) { |
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, | |
| } | |
| }; |
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
| 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
| 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
| 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
| 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 PasswordValidator { | |
| bool call(String password) { | |
| return password.length > 10; | |
| } | |
| } |