Take this as an example:
class User {
User({int id = 0, String name = 'anonymous'})
: _id = id,
_name = name;
int _id;
String _name;
}
I find that there is no error if I remove the argument type in the constructor:
class User {
User({id = 0, name = 'anonymous'})
: _id = id,
_name = name;
int _id;
String _name;
}
Is there any difference between the two? When do we need to specify the argument type in the constructor?