-
Notifications
You must be signed in to change notification settings - Fork 16
Description
The alpha parameter for Color.withValues is a double representing opacity in the range 0.0–1.0 (e.g., alpha: 0.5 = 50% opacity). For reference, Color.withAlpha(int) still uses 0–255.
Fix Color.withValues(alpha:) parameter range—using 0–255 values clamps all colors to fully opaque.
Color.withValues() expects alpha in the range 0.0–1.0, but the codebase uses 0–255 values (13, 25, 51, 76, 127, 153, 178) which all clamp to 1.0 (fully opaque), defeating the intended transparency. Comments in the code confirm the developer's intent (e.g., alpha: 51 // 0.2 opacity), but the values are incompatible with the API.
Convert all affected usages:
alpha: 13→alpha: 0.051alpha: 25→alpha: 0.098alpha: 51→alpha: 0.2alpha: 76→alpha: 0.3alpha: 127→alpha: 0.5alpha: 153→alpha: 0.6alpha: 178→alpha: 0.7
Affected files: encrypted_file_message.dart, encrypted_image_message.dart, message_input.dart, chat_list_item.dart, dispute_message_input.dart, info_buttons.dart.
🤖 Prompt for AI Agents
In lib/features/chat/widgets/encrypted_file_message.dart around lines 96 to 100
the call Color.withValues(alpha: 51) uses an invalid alpha range (0.0–1.0)
causing values like 51 to clamp to 1.0; change the alpha to the correct
fractional value (e.g., 51 -> 0.2) and apply the same fixes across the other
affected files (encrypted_image_message.dart, message_input.dart,
chat_list_item.dart, dispute_message_input.dart, info_buttons.dart). Replace
13->0.051, 25->0.098, 51->0.2, 76->0.3, 127->0.5, 153->0.6, 178->0.7 wherever
Color.withValues(alpha: ...) is used so the intended transparency is preserved.
Originally posted by @coderabbitai[bot] in #367 (comment)