Migration guide for wide gamut CupertinoDynamicColor
Summary
#
                  Certain properties and methods in CupertinoDynamicColor
                   were deprecated
                  to align with the Color
                   class due to wide gamut color spaces support
                  added in Flutter 3.27.
                
Context
#
                  The Color class was updated to support wide gamut color spaces,
                  but some corresponding deprecations were not initially applied to
                  CupertinoDynamicColor due to its implementation rather than
                  due to the extension of Color.
                
Description of change
#- 
                     The 
CupertinoDynamicColor.redfield is deprecated in favor ofCupertinoDynamicColor.r. - 
                     The 
CupertinoDynamicColor.greenis deprecated in favor ofCupertinoDynamicColor.g. - 
                     The 
CupertinoDynamicColor.blueis deprecated in favor ofCupertinoDynamicColor.b. - 
                     The 
CupertinoDynamicColor.opacityis deprecated in favor ofCupertinoDynamicColor.a. - 
                     The 
CupertinoDynamicColor.withOpacity()is deprecated in favor ofCupertinoDynamicColor.withValues(). 
Migration guide
#Access color components
#If your app accesses a single color component, consider taking advantage of the floating-point components. In the short term, you can scale the components themselves.
int _floatToInt8(double x) {
  return (x * 255.0).round().clamp(0, 255);
}
const CupertinoDynamicColor color = CupertinoColors.systemBlue;
final intRed = _floatToInt8(color.r);
final intGreen = _floatToInt8(color.g);
final intBlue = _floatToInt8(color.b);
                    
                    
                    
                  Opacity
#
                  Before Flutter 3.27, Color had the concept of "opacity", which
                  showed up in the methods opacity and withOpacity().
                  Since Flutter 3.27, the alpha channel has been stored as a floating-point value.
                  Using .a and .withValues() will give the full expression of
                  a floating-point value and won't be quantized (restricted to a limited range).
                  That means "alpha" expresses the intent of "opacity" more correctly.
                
Migrate opacity
                  #
                // Before: Access the alpha channel as a (converted) floating-point value.
final x = color.opacity;
// After: Access the alpha channel directly.
final x = color.a;
                    
                    
                    
                  Migrate withOpacity
                  #
                // Before: Create a new color with the specified opacity.
final x = color.withOpacity(0.5);
// After: Create a new color with the specified alpha channel value,
// accounting for the current or specified color space.
final x = color.withValues(alpha: 0.5);
                    
                    
                    
                  Timeline
#
                  Landed in version: 3.36.0-0.1.pre
                  Stable release: 3.38
                
References
#Relevant guides:
Relevant issues:
- Implement wide gamut color support in the Framework
 - CupertinoDynamicColor is missing deprecation notices
 
Relevant PRs:
Unless stated otherwise, the documentation on this site reflects Flutter 3.35.5. Page last updated on 2025-11-3. View source or report an issue.