From aeb289fce66e5d68dcb33033d3600e9f674b0575 Mon Sep 17 00:00:00 2001 From: RuiAlonso Date: Mon, 7 Mar 2022 13:04:28 +0100 Subject: [PATCH] fix: changed paths area default color to transparent --- lib/game/components/path.dart | 8 +++----- test/game/components/path_test.dart | 9 ++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/game/components/path.dart b/lib/game/components/path.dart index 0d7105d7..66dad004 100644 --- a/lib/game/components/path.dart +++ b/lib/game/components/path.dart @@ -10,11 +10,9 @@ class Path extends BodyComponent { required List> paths, }) : _position = position, _paths = paths { - if (color != null) { - paint = Paint() - ..color = color - ..style = PaintingStyle.stroke; - } + paint = Paint() + ..color = color ?? const Color.fromARGB(0, 0, 0, 0) + ..style = PaintingStyle.stroke; } factory Path.straight({ diff --git a/test/game/components/path_test.dart b/test/game/components/path_test.dart index a97ba866..9564c21c 100644 --- a/test/game/components/path_test.dart +++ b/test/game/components/path_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: cascade_invocations +// ignore_for_file: cascade_invocations, prefer_const_constructors import 'package:flame_forge2d/flame_forge2d.dart'; import 'package:flame_test/flame_test.dart'; import 'package:flutter/material.dart'; @@ -15,7 +15,7 @@ void main() { group('straight', () { group('color', () { flameTester.test( - 'has white color by default if not specified', + 'has transparent color by default if not specified', (game) async { final path = Path.straight( position: Vector2.zero(), @@ -26,7 +26,10 @@ void main() { await game.ensureAdd(path); expect(game.contains(path), isTrue); expect(path.paint, isNotNull); - expect(path.paint.color, equals(Colors.white)); + expect( + path.paint.color, + equals(Color.fromARGB(0, 0, 0, 0)), + ); }, ); flameTester.test(