From accbc0009bb0602529393c524cfb4ae22eb11fda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Harrault?= <benoit@harrault.fr> Date: Fri, 20 Dec 2024 17:10:17 +0100 Subject: [PATCH] Remove deprecations --- CHANGELOG.md | 4 ++++ lib/theme/theme.dart | 4 ++-- lib/utils/color_extensions.dart | 31 ++++++++++++++++--------------- pubspec.yaml | 2 +- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34944b9..3514093 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.8.2 + +- Remove deprecations + ## 0.8.1 - Fix autosized text in styled buttons diff --git a/lib/theme/theme.dart b/lib/theme/theme.dart index 138460e..815a0eb 100644 --- a/lib/theme/theme.dart +++ b/lib/theme/theme.dart @@ -42,7 +42,7 @@ final ColorScheme lightColorScheme = ColorScheme.light( onSurface: textSwatch.shade500, surface: textSwatch.shade50, surfaceContainerHighest: Colors.white, - shadow: textSwatch.shade900.withOpacity(.1), + shadow: textSwatch.shade900.withValues(alpha: .1), ); final ColorScheme darkColorScheme = ColorScheme.dark( @@ -53,7 +53,7 @@ final ColorScheme darkColorScheme = ColorScheme.dark( onSurface: textSwatch.shade300, surface: const Color(0xFF262630), surfaceContainerHighest: const Color(0xFF282832), - shadow: textSwatch.shade900.withOpacity(.2), + shadow: textSwatch.shade900.withValues(alpha: .2), ); final ThemeData lightTheme = ThemeData( diff --git a/lib/utils/color_extensions.dart b/lib/utils/color_extensions.dart index 4e55e33..eca0e55 100644 --- a/lib/utils/color_extensions.dart +++ b/lib/utils/color_extensions.dart @@ -4,30 +4,31 @@ extension ColorExtension on Color { Color darken([int percent = 40]) { assert(1 <= percent && percent <= 100); final value = 1 - percent / 100; - return Color.fromARGB( - alpha, - (red * value).round(), - (green * value).round(), - (blue * value).round(), + return Color.from( + alpha: a, + red: r * value, + green: g * value, + blue: b * value, ); } Color lighten([int percent = 40]) { assert(1 <= percent && percent <= 100); final value = percent / 100; - return Color.fromARGB( - alpha, - (red + ((255 - red) * value)).round(), - (green + ((255 - green) * value)).round(), - (blue + ((255 - blue) * value)).round(), + return Color.from( + alpha: a, + red: r + ((1 - r) * value), + green: g + ((1 - g) * value), + blue: b + ((1 - b) * value), ); } Color avg(Color other) { - final red = (this.red + other.red) ~/ 2; - final green = (this.green + other.green) ~/ 2; - final blue = (this.blue + other.blue) ~/ 2; - final alpha = (this.alpha + other.alpha) ~/ 2; - return Color.fromARGB(alpha, red, green, blue); + return Color.from( + alpha: (a + other.a) / 2, + red: (r + other.r) / 2, + green: (g + other.g) / 2, + blue: (b + other.b) / 2, + ); } } diff --git a/pubspec.yaml b/pubspec.yaml index 8707a1a..e9f6af4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: "Flutter custom toolbox for org.benoitharrault.* projects." publish_to: "none" -version: 0.8.1 +version: 0.8.2 homepage: https://git.harrault.fr/android/flutter-toolbox -- GitLab