Skip to content

Instantly share code, notes, and snippets.

@Sp4Rx
Created May 20, 2020 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sp4Rx/4754df691540131aa8257d722a39134c to your computer and use it in GitHub Desktop.
Save Sp4Rx/4754df691540131aa8257d722a39134c to your computer and use it in GitHub Desktop.
Just to check what dart returns if there is no key
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