obsolete_colon_for_default_value
Using a colon as the separator before a default value is no longer supported.
Description
#The analyzer produces this diagnostic when a colon (:
) is used as the separator before the default value of an optional named parameter. While this syntax used to be allowed, it was removed in favor of using an equal sign (=
).
Example
#The following code produces this diagnostic because a colon is being used before the default value of the optional parameter i
:
dart
void f({int i : 0}) {}
Common fixes
#Replace the colon with an equal sign:
dart
void f({int i = 0}) {}
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.