Created
May 20, 2020 12:45
-
-
Save Sp4Rx/4754df691540131aa8257d722a39134c to your computer and use it in GitHub Desktop.
Just to check what dart returns if there is no key
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() { | |
var data = {'key': 'value'}; | |
try { | |
var value = data['wrongKey']; | |
print(value); | |
value = data['key']; | |
print(value); | |
print('---------------'); | |
//This is just to simulate an error | |
print(2 * int.parse(data['error'])); | |
} catch (_) { | |
print('ERROR:'); | |
print(_); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment