Skip to content

Fix Color.withValues(alpha:) parameter range—using 0–255 values clamps all colors to fully opaque #373

@Catrya

Description

@Catrya

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: 13alpha: 0.051
  • alpha: 25alpha: 0.098
  • alpha: 51alpha: 0.2
  • alpha: 76alpha: 0.3
  • alpha: 127alpha: 0.5
  • alpha: 153alpha: 0.6
  • alpha: 178alpha: 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)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions