-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #890 from diegotori/fix_issue_888
Fix issue 888
- Loading branch information
Showing
6 changed files
with
128 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
//ignore_for_file: deprecated_member_use | ||
extension ColorCompatExtensions on Color { | ||
/// Returns a new color that matches this color with the given opacity. | ||
/// | ||
/// This is a compatibility layer that ensures compatibility with Flutter | ||
/// versions below 3.27. In Flutter 3.27 and later, `Color.withOpacity` | ||
/// has been deprecated in favor of `Color.withValues`. | ||
/// | ||
/// This method bridges the gap by providing a consistent way to adjust | ||
/// the opacity of a color across different Flutter versions. | ||
/// | ||
/// **Important:** Once the minimum supported Flutter version is bumped | ||
/// to 3.27 or higher, this method should be removed and replaced with | ||
/// `withValues(alpha: opacity)`. | ||
/// | ||
/// See also: | ||
/// * [Color.withOpacity], which is deprecated in Flutter 3.27 and later. | ||
/// * [Color.withValues], the recommended replacement for `withOpacity`. | ||
Color withOpacityCompat(double opacity) { | ||
// Compatibility layer that uses the legacy withOpacity method, while | ||
// ignoring the deprecation for now (in order to guarantee N-1 minimum | ||
// version compatibility). | ||
// Once it's removed from a future update, we'll have to replace uses of | ||
// this method with withValues(alpha: opacity). | ||
// TODO: Replace this bridge method once the above holds true. | ||
return withOpacity(opacity); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters