class Student {
String name;
int age;
int id;
Student({this.name, this.id = 101, this.age: 20});
}
What is the difference between =
and :
in above constructor? Both seems to do the same job.
From the documentation:
Deprecation note: Old code might use a colon (:) instead of = to set default values of named parameters. The reason is that originally, only : was supported for named parameters. That support is likely to be deprecated, so we recommend that you use = to specify default values.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.