Skip to content
Open
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
12 changes: 6 additions & 6 deletions example/lib/main_side_by_side_comparison.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
13 changes: 9 additions & 4 deletions lib/src/box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down