-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
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
SDK Error #39078
Comments
Try this: void main() {
Test test = Test.fromMap(null);
//throw Exception
}
class Test {
String id;
String name;
Test();
factory Test.fromMap(Map map) => map == null ? Test() : (Test()
..id = map["id"]
..name = map["name"]);
} The problem is that you are using a cascade whose receiver (that is, It is a known source of confusion that cascades have such a low precedence. However, if we want to allow the right hand side of a cascade assignment to contain a wide assortment of expressions then the precedence has to be low. In particular, with |
@eernstg thank. |
Thanks! For prior discussions about the precence of the cascade syntax, please follow #608 (that's an old issue which was moved here from the SDK repository, so it's much older than the number 608 would imply). |
SDK version
2.5.0
You can use this code and run it.
result:
The text was updated successfully, but these errors were encountered: