We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to cast easyly.
because it is too long. List<int> hoge = map['hoge']?.cast<int>() ?? [];
List<int> hoge = map['hoge']?.cast<int>() ?? [];
I want to do this.
List<int> hoge = map['hoge'].safecast<int>();
The text was updated successfully, but these errors were encountered:
I'm not sure whether this is something many users would find useful. Is there a language which has a similar method?
There are many examples where we could add a "safe" method but I don't think cluttering the auto complete is worth it.
Example:
5.safeAdd(7) // -> 13 null.safeAdd(7) // -> 7
Sorry, something went wrong.
I've constantly ran into similar problems when parsing json responses, that's why I created the deep_pick package.
deep_pick
Your code would become:
List<int>? hoge = pick(map, 'hoge').asListOrNull(); List<int> hoge = pick(map, 'hoge').asListOrEmpty();
@passsy Thank you. I will be considering use it
No branches or pull requests
I want to cast easyly.
because it is too long.
List<int> hoge = map['hoge']?.cast<int>() ?? [];
I want to do this.
List<int> hoge = map['hoge'].safecast<int>();
The text was updated successfully, but these errors were encountered: