Commit d5e2791 1 parent 976ed7e commit d5e2791 Copy full SHA for d5e2791
File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -15089,6 +15089,40 @@ class C {
15089
15089
}
15090
15090
` ` `
15091
15091
15092
+ # ## non_const_argument_for_const_parameter
15093
+
15094
+ _Argument '{0}' must be a constant._
15095
+
15096
+ # ### Description
15097
+
15098
+ The analyzer produces this diagnostic when a parameter is
15099
+ annotated with the `@mustBeConst` annotation and the
15100
+ corresponding argument is not a constant expression.
15101
+
15102
+ # ### Example
15103
+
15104
+ The following code produces this diagnostic on the invocation of
15105
+ the function `f` because the value of the argument passed to the
15106
+ function `g` isn't a constant :
15107
+
15108
+ ` ` ` dart
15109
+ import 'package:meta/meta.dart' show mustBeConst;
15110
+ int f(int value) => g([!value!]);
15111
+ int g(@mustBeConst int value) => value + 1;
15112
+ ` ` `
15113
+
15114
+ # ### Common fixes
15115
+
15116
+ If a suitable constant is available to use, then replace the argument
15117
+ with a constant :
15118
+
15119
+ ` ` ` dart
15120
+ import 'package:meta/meta.dart' show mustBeConst;
15121
+ const v = 3;
15122
+ int f() => g(v);
15123
+ int g(@mustBeConst int value) => value + 1;
15124
+ ` ` `
15125
+
15092
15126
# ## non_const_call_to_literal_constructor
15093
15127
15094
15128
_This instance creation must be 'const', because the {0} constructor is marked
You can’t perform that action at this time.
0 commit comments