Created with <3 with dartpad.dev.
Created
October 5, 2023 15:47
-
-
Save MelvinRB27/585aa184c7eda59c91c0ab6dcad85915 to your computer and use it in GitHub Desktop.
try, catch
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() async { | |
try { | |
final value = await httpGet("melvin"); | |
print(value); | |
} catch (err) { | |
print('Error: $err'); | |
} | |
} | |
Future<String> httpGet(String url) async { | |
await Future.delayed(Duration(seconds: 1)); | |
//return 'Respuesta http'; | |
throw 'Hubo un error'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment