@@ -64,30 +64,40 @@ extension type const {{NAME}}._(int _) implements int {
64
64
static const _descriptor = IntDescriptor<{{NAME}}>.{{CONSTRUCTOR}}(
65
65
{{NAME}}.fromUnchecked,
66
66
width: width,
67
- max: {{MAX}} ,
67
+ max: maxInt ,
68
68
);
69
69
70
+ /// The minimum value that this type can represent, as a plain [int].
71
+ ///
72
+ /// This is equivalent to `{{NAME}}.min as int`.
73
+ static const minInt = {{MIN}};
74
+
75
+ /// The maximum value that this type can represent, as a plain [int].
76
+ ///
77
+ /// This is equivalent to `{{NAME}}.max as int`.
78
+ static const maxInt = {{MAX}};
79
+
70
80
/// Always `0`.
71
81
static const zero = {{NAME}}.fromUnchecked(0);
72
82
73
83
/// Always `1`.
74
84
static const one = {{NAME}}.fromUnchecked(1);
75
85
76
86
/// The minimum value that this type can represent.
77
- static const min = {{NAME}}.fromUnchecked({{MIN}} );
87
+ static const min = {{NAME}}.fromUnchecked(minInt );
78
88
79
89
/// The maximum value that this type can represent.
80
- static const max = {{NAME}}.fromUnchecked({{MAX}} );
90
+ static const max = {{NAME}}.fromUnchecked(maxInt );
81
91
82
92
/// The number of bits used to represent values of this type.
83
93
static const width = {{WIDTH}};
84
94
85
95
/// Returns whether [v] is in a valid range for {{NAME}}.
86
- static bool isValid(int v) => v >= {{MIN}} && v <= {{MAX}} ;
96
+ static bool isValid(int v) => v >= minInt && v <= maxInt ;
87
97
88
98
/// Throws a [RangeError] if [value] is not in a valid range for {{NAME}}.
89
99
static void checkRange(int value) {
90
- RangeError.checkValueInInterval(value, {{MIN}}, {{MAX}} , 'value');
100
+ RangeError.checkValueInInterval(value, minInt, maxInt , 'value');
91
101
}
92
102
93
103
/// Defines [v] as {{DESCRIPTION}}, wrapping if necessary.
@@ -106,7 +116,7 @@ extension type const {{NAME}}._(int _) implements int {
106
116
// Dart2JS crashes if the boolean is first in this expression, but have
107
117
// not been able to reproduce it in a minimal example yet, so this is a
108
118
// workaround.
109
- v >= {{MIN}} && v <= {{MAX}} || !debugCheckUncheckedInRange ,
119
+ v >= minInt && v <= maxInt || !debugCheckUncheckedInRange ,
110
120
'Value out of range: $v.\n\n'
111
121
'This should never happen, and is likely a bug. To intentionally '
112
122
'overflow, even in debug mode, set '
0 commit comments