Skip to content

revert deprecating Color withOpacity / opacity #162069

@lukepighetti

Description

@lukepighetti

Read through the code and migration guide but still having trouble supporting the end result here.

Axioms

  1. the vast majority of production codebases use .withOpacity(x), where x is 0.0–1.0 1
  2. the internal implementation is now .withOpacity(x) => .withAlpha((255.0*x).round()); 2
  3. the migration docs say to migrate .withOpacity(x) => .withValues(alpha: x); 3
  4. .withValues(alpha: x) is more verbose and less obvious than .withOpacity(x) 4
  5. designers communicate opacity as a percentage from 0%–100% not an integer from 0–255 5

Questions

  1. why doesn't the internal implementation match the migration docs
  2. why does withAlpha(x) take an int 0–255 and withValues(alpha: x) take a double 0–1.0
  3. why does .withOpacity need to be deprecated at all

Recommendations

  1. unify alpha to a double or an int across all color methods
  2. undeprecate withOpacity method
  3. undeprecate opacity getter

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: proposalA detailed proposal for a change to Fluttercustomer: crowdAffects or could affect many people, though not necessarily a specific customer.engineflutter/engine related. See also e: labels.r: solvedIssue is closed as solvedteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions