diff --git a/example/lib/main_side_by_side_comparison.dart b/example/lib/main_side_by_side_comparison.dart index d2d19d7..66efd34 100644 --- a/example/lib/main_side_by_side_comparison.dart +++ b/example/lib/main_side_by_side_comparison.dart @@ -12,7 +12,7 @@ class Demo extends StatelessWidget { const Demo({super.key}); static var w1 = Box( - color: Colors.red.withValues(alpha: 0.2), + color: Colors.red.withOpacity(0.2), child: const Text( "Hello there!", style: TextStyle(color: Colors.red), @@ -21,7 +21,7 @@ class Demo extends StatelessWidget { ); static var w2 = Box( - color: Colors.blue.withValues(alpha: 0.2), + color: Colors.blue.withOpacity(0.2), child: const Text( "How are you doing?", style: TextStyle(color: Colors.blue), @@ -31,7 +31,7 @@ class Demo extends StatelessWidget { static var w3 = Box( alignment: Alignment.centerLeft, - color: Colors.green.withValues(alpha: 0.2), + color: Colors.green.withOpacity(0.2), child: const Text( "I'm doing fine.", style: TextStyle(color: Colors.green), @@ -40,7 +40,7 @@ class Demo extends StatelessWidget { ); static var w1Rtl = Box( - color: Colors.red.withValues(alpha: 0.2), + color: Colors.red.withOpacity(0.2), child: const Text( "שלום!", textDirection: TextDirection.rtl, @@ -50,7 +50,7 @@ class Demo extends StatelessWidget { ); static var w2Rtl = Box( - color: Colors.blue.withValues(alpha: 0.2), + color: Colors.blue.withOpacity(0.2), child: const Text( "מה שלומך?", textDirection: TextDirection.rtl, @@ -60,7 +60,7 @@ class Demo extends StatelessWidget { ); static var w3Rtl = Box( - color: Colors.green.withValues(alpha: 0.2), + color: Colors.green.withOpacity(0.2), child: const Text( "אני בסדר.", textDirection: TextDirection.rtl, diff --git a/lib/src/box.dart b/lib/src/box.dart index 78f9191..776d675 100644 --- a/lib/src/box.dart +++ b/lib/src/box.dart @@ -257,17 +257,22 @@ class Box extends StatelessWidget { double r = (color == null) ? (30 + rand.nextInt(196)) / 255.0 - : (color.r + rand.nextDouble()) / 2; + : (color.red / 255.0 + rand.nextDouble()) / 2; double g = (color == null) ? (30 + rand.nextInt(196)) / 255.0 - : (color.g + rand.nextDouble()) / 2; + : (color.green / 255.0 + rand.nextDouble()) / 2; double b = (color == null) ? (30 + rand.nextInt(196)) / 255.0 - : (color.b + rand.nextDouble()) / 2; + : (color.blue / 255.0 + rand.nextDouble()) / 2; - color = Color.from(alpha: 1.0, red: r, green: g, blue: b); + color = Color.fromRGBO( + (r * 255).round(), + (g * 255).round(), + (b * 255).round(), + 1.0, + ); } if (decoration != null) {