Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion packages/enhanced_gradients/.fvmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"flutter": "3.19.6"
"flutter": "3.27.2"
}
4 changes: 4 additions & 0 deletions packages/enhanced_gradients/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.0.0

- BREAKING CHANGE: Raise minimum Flutter version to 3.27.0 which supports wide gamut color spaces.

## 2.0.0

- BREAKING CHANGE: Raise minimum Flutter version to 3.19.0. Previous versions of enhanced_gradients were incompatible with Flutter 3.19 due to dependency constraints.
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include: package:flutter_lints/flutter.yaml
include: package:leancode_lint/analysis_options.yaml
6 changes: 3 additions & 3 deletions packages/enhanced_gradients/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ publish_to: "none"
version: 0.1.0

environment:
sdk: ">=3.0.0 <4.0.0"
flutter: ">=3.10.0"
sdk: ">=3.6.0 <4.0.0"
flutter: ">=3.27.0"

dependencies:
enhanced_gradients:
Expand All @@ -16,7 +16,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
leancode_lint: ^15.0.0

flutter:
uses-material-design: true
24 changes: 18 additions & 6 deletions packages/enhanced_gradients/lib/src/hct_color_tween.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,31 @@ Color? lerpHct(Color? colorA, Color? colorB, double t) =>
};

Color _lerpHctNonNullable(Color colorA, Color colorB, double t) {
final beginHct = Hct.fromInt(colorA.value);
final endHct = Hct.fromInt(colorB.value);
final beginHct = Hct.fromInt(_colorToInt(colorA));
final endHct = Hct.fromInt(_colorToInt(colorB));

final opacity = lerpDouble(colorA.opacity, colorB.opacity, t)!;
final alpha = lerpDouble(colorA.a, colorB.a, t)!;
final hue = lerpDegrees(beginHct.hue, endHct.hue, t)!;
final chroma = lerpDouble(beginHct.chroma, endHct.chroma, t)!;
final tone = lerpDouble(beginHct.tone, endHct.tone, t)!;

return Color(
Hct.from(hue, chroma, tone).toInt(),
).withOpacity(opacity);
).withValues(alpha: alpha);
}

Color _scaleAlpha(Color a, double factor) {
return a.withAlpha((a.alpha * factor).round().clamp(0, 255));
Color _scaleAlpha(Color color, double factor) {
return color.withValues(alpha: color.a * factor);
}

/// [Hct] requires int values, so we need to convert [Color].
int _colorToInt(Color color) {
return _floatToInt8(color.a) << 24 |
_floatToInt8(color.r) << 16 |
_floatToInt8(color.g) << 8 |
_floatToInt8(color.b) << 0;
}

int _floatToInt8(double x) {
return (x * 255.0).round() & 0xff;
}
8 changes: 4 additions & 4 deletions packages/enhanced_gradients/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: enhanced_gradients
version: 2.0.0
version: 3.0.0
homepage: https://github.com/leancodepl/flutter_corelibrary/tree/master/packages/enhanced_gradients
repository: https://github.com/leancodepl/flutter_corelibrary
description: >-
Expand All @@ -10,14 +10,14 @@ environment:
flutter: ">=3.19.0"

dependencies:
collection: ^1.17.1
collection: ^1.19.0
flutter:
sdk: flutter
material_color_utilities: any
material_color_utilities: ^0.11.1

dev_dependencies:
flutter_test:
sdk: flutter
glados: ^1.1.6
leancode_lint: ">=12.1.0 <15.0.0"
leancode_lint: ^15.0.0
meta: ^1.9.1
Loading