From 0e427339050aaf77e9fa251975564d46633ce930 Mon Sep 17 00:00:00 2001 From: Matias de Andrea Date: Tue, 10 Feb 2026 18:18:05 +0100 Subject: [PATCH 1/2] fix: update color property accessors to match Flutter's stable API --- lib/src/surveys/models/survey_appearance.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/surveys/models/survey_appearance.dart b/lib/src/surveys/models/survey_appearance.dart index 4feaf296..7850acfc 100644 --- a/lib/src/surveys/models/survey_appearance.dart +++ b/lib/src/surveys/models/survey_appearance.dart @@ -113,9 +113,9 @@ class SurveyAppearance { /// Uses the HSP (Highly Sensitive Perceived) color model for perceived brightness. /// This matches the algorithm used in posthog-js. static Color _getContrastingTextColor(Color color) { - final r = color.red; - final g = color.green; - final b = color.blue; + final r = color.r; + final g = color.g; + final b = color.b; // HSP equation for perceived brightness final hsp = sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b)); // Using 127.5 as threshold (same as JS) From 3282654ede188e6794c98bd676c7b1744b00da37 Mon Sep 17 00:00:00 2001 From: Matias de Andrea Date: Wed, 11 Feb 2026 19:52:50 +0100 Subject: [PATCH 2/2] fix: adjust color value calculations for contrasting text color --- lib/src/surveys/models/survey_appearance.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/surveys/models/survey_appearance.dart b/lib/src/surveys/models/survey_appearance.dart index 7850acfc..df35bfb2 100644 --- a/lib/src/surveys/models/survey_appearance.dart +++ b/lib/src/surveys/models/survey_appearance.dart @@ -113,9 +113,9 @@ class SurveyAppearance { /// Uses the HSP (Highly Sensitive Perceived) color model for perceived brightness. /// This matches the algorithm used in posthog-js. static Color _getContrastingTextColor(Color color) { - final r = color.r; - final g = color.g; - final b = color.b; + final r = (color.r * 255.0).round().clamp(0, 255); + final g = (color.g * 255.0).round().clamp(0, 255); + final b = (color.b * 255.0).round().clamp(0, 255); // HSP equation for perceived brightness final hsp = sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b)); // Using 127.5 as threshold (same as JS)