What is the difference between these two syntaxes for setting a default value for a parameter in Dart:
class Test {
Test({
int x: 2,
int y = 3,
});
}
I tried both of them and they seem to be completely identical.
What is the difference between these two syntaxes for setting a default value for a parameter in Dart:
class Test {
Test({
int x: 2,
int y = 3,
});
}
I tried both of them and they seem to be completely identical.
They're the same. At least for now. The language tour says:
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 might be deprecated, so we recommend that you use = to specify default values.
So avoid using the colon in the future as it may be removed at some point.