Resonate icon indicating copy to clipboard operation
Resonate copied to clipboard

Changes to the Color API make current usage of Color.toString() broken

Open M4dhav opened this issue 8 months ago • 1 comments

🐛 Describe the bug

The recent changes to the Color API resulted in the Color.toString() method returning a String representing the object:

Color(alpha: 1.0000, red: 0.7961, green: 0.9490, blue: 0.3608, colorSpace: ColorSpace.sRGB)

But the way this is currently used in the code, it expects the method to return a Color Hex Code that can later be used to reform the Colors after fetching hexcodes from the database. This has currently broken the entirety of the Stories and Chapters flow:

flutter (14324): #0      int._handleFormatError (dart:core-patch/integers_patch.dart:127:5)
E/flutter (14324): #1      int._parseRadix (dart:core-patch/integers_patch.dart:171:16)
E/flutter (14324): #2      int._parse (dart:core-patch/integers_patch.dart:94:18)
E/flutter (14324): #3      int.parse (dart:core-patch/integers_patch.dart:61:12)
E/flutter (14324): #4      ExploreStoryController.convertAppwriteDocListToStoryList.<anonymous closure> (package:resonate/controllers/explore_story_controller.dart:517:35)
E/flutter (14324): #8      new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
E/flutter (14324): #9      new List.of (dart:core-patch/array_patch.dart:39:18)
E/flutter (14324): #11     ExploreStoryController.convertAppwriteDocListToStoryList (package:resonate/controllers/explore_story_controller.dart:536:8)
E/flutter (14324): #12     ExploreStoryController.fetchUserCreatedStories (package:resonate/controllers/explore_story_controller.dart:390:15)
E/flutter (14324): #13     ExploreStoryController.createStory (package:resonate/controllers/explore_story_controller.dart:276:5)

I propose a simple fix by adding an Extension method to the color class that can handle this conversion of the Color to it's Hex Code

M4dhav avatar Mar 26 '25 13:03 M4dhav

@Aarush-Acharya please assign this to me

M4dhav avatar Mar 26 '25 14:03 M4dhav