Run ❯
Get your
own
website
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Change Language
Go to Spaces
Ctrl+Alt+P
Future
getStock(String fruit) async { await Future.delayed(Duration(seconds: 1)); if (fruit == 'mango') { throw Exception('No mangos today'); } return 12; } Future
main() async { try { int apples = await getStock('apple'); print('Apples: $apples'); int mangos = await getStock('mango'); print('Mangos: $mangos'); } catch (e) { print('Error: $e'); } finally { print('Done checking'); } }
Apples: 12
Error: Exception: No mangos today
Done checking