Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/netglade_flutter_utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Unreleased
## 1.4.0
- Require Dart SDK 3.10.0 or later.
- *Add* `withAlphaPercent` method to Color extension to set alpha using percentage.
- Dependencies update.

## 1.3.0
- Require Dart SDK 3.9.0 or later.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,15 @@ extension ColorExtensions on Color {

return asUpperCase ? result.toUpperCase() : result;
}

/// Returns color with alpha set to [percent].
///
/// Corresponds with deprecated withOpacity method.
Color withAlphaPercent(double percent) {
assert(percent >= 0 && percent <= 1, 'percent must be between 0 and 1');

final alphaValue = (percent * 255).toInt().clamp(0, 255);

return withAlpha(alphaValue);
}
}
2 changes: 1 addition & 1 deletion packages/netglade_flutter_utils/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: netglade_flutter_utils
resolution: workspace
description: Flutter utils used internally at netglade.
version: 1.3.0
version: 1.4.0
repository: https://github.com/netglade/flutter_core/tree/main/packages/netglade_flutter_utils
issue_tracker: https://github.com/netglade/flutter_core/issues
homepage: https://github.com/netglade/flutter_core
Expand Down