@@ -310,6 +310,66 @@ void main() {
310
310
expect (hotelsSortWithRestaurantKey.last['price' ], 100 );
311
311
});
312
312
});
313
+
314
+ group ('getColor Tests' , () {
315
+ const myColor = Color (0xff123456 );
316
+
317
+ test ('color hex with #' , () {
318
+ expect (Utils .getColor ('#123456' ), equals (myColor));
319
+ });
320
+
321
+ test ('color hex without #' , () {
322
+ expect (Utils .getColor ('123456' ), equals (myColor));
323
+ });
324
+
325
+ test ('hex with alpha and #' , () {
326
+ expect (Utils .getColor ('#123456ff' ), equals (myColor));
327
+ });
328
+
329
+ test ('hex with alpha' , () {
330
+ expect (Utils .getColor ('123456ff' ), equals (myColor));
331
+ });
332
+
333
+ test ('returns null for invalid hex string' , () {
334
+ expect (Utils .getColor ('12345g' ), isNull);
335
+ });
336
+
337
+ test ('returns Color for valid integer color value' , () {
338
+ expect (Utils .getColor (0xff123456 ), equals (const Color (0xff123456 )));
339
+ });
340
+
341
+ test ('test color as a string' , () {
342
+ expect (Utils .getColor ("0xff123456" ), equals (const Color (0xff123456 )));
343
+ });
344
+
345
+ test ('returns correct Color for named color strings' , () {
346
+ expect (Utils .getColor ('red' ), equals (Colors .red));
347
+ expect (Utils .getColor ('blue' ), equals (Colors .blue));
348
+ });
349
+
350
+ test ('returns Colors.transparent for transparent string' , () {
351
+ expect (Utils .getColor ('transparent' ), equals (Colors .transparent));
352
+ });
353
+
354
+ test ('returns null for non-string, non-int types' , () {
355
+ expect (Utils .getColor ([255 , 0 , 0 ]), isNull);
356
+ });
357
+
358
+ test ('returns null for undefined named colors' , () {
359
+ expect (Utils .getColor ('not a color' ), isNull);
360
+ });
361
+
362
+ test ('returns correct Color for transparent keyword variations' , () {
363
+ expect (Utils .getColor ('.transparent' ), equals (Colors .transparent));
364
+ });
365
+
366
+ // Additional tests for each named color
367
+ test ('returns correct Color for each named color string' , () {
368
+ expect (Utils .getColor ('black' ), equals (Colors .black));
369
+ expect (Utils .getColor ('white' ), equals (Colors .white));
370
+ // Continue testing all other named colors...
371
+ });
372
+ });
313
373
}
314
374
315
375
void assertIconEquality (IconModel first, IconModel second) {
0 commit comments