@@ -176,6 +176,24 @@ const white = [!Color(0xFFFFFFFF)!];
176
176
);
177
177
}
178
178
179
+ /// If a color is in a const context, we should not insert 'const'.
180
+ Future <void > test_colorConstructor_constContext_withSeparators () async {
181
+ content = '''
182
+ import 'package:flutter/material.dart';
183
+
184
+ const white = [!Color(0xFF_FF_FF_FF)!];
185
+ ''' ;
186
+
187
+ await _checkPresentations (
188
+ select: Color (alpha: 1 , red: 1 , green: 0 , blue: 0 ),
189
+ expectPresentations: [
190
+ _color ('Color.fromARGB(255, 255, 0, 0)' ),
191
+ _color ('Color.fromRGBO(255, 0, 0, 1)' ),
192
+ _color ('Color(0xFFFF0000)' ),
193
+ ],
194
+ );
195
+ }
196
+
179
197
/// If a color already has 'const' ahead of it, we should include it in the
180
198
/// replacement also.
181
199
Future <void > test_colorConstructor_constKeyword () async {
@@ -212,6 +230,23 @@ var white = [!Color(0xFFFFFFFF)!];
212
230
);
213
231
}
214
232
233
+ Future <void > test_colorConstructor_nonConst_withSeparators () async {
234
+ content = '''
235
+ import 'package:flutter/material.dart';
236
+
237
+ var white = [!Color(0xFF_FF_FF_FF)!];
238
+ ''' ;
239
+
240
+ await _checkPresentations (
241
+ select: Color (alpha: 1 , red: 1 , green: 0 , blue: 0 ),
242
+ expectPresentations: [
243
+ _color ('Color.fromARGB(255, 255, 0, 0)' ),
244
+ _color ('Color.fromRGBO(255, 0, 0, 1)' ),
245
+ _color ('Color(0xFFFF0000)' ),
246
+ ],
247
+ );
248
+ }
249
+
215
250
Future <void > test_includesImportEdit () async {
216
251
failTestOnErrorDiagnostic = false ; // Tests with missing import.
217
252
0 commit comments