fix: changed paths area default color to transparent

pull/14/head
RuiAlonso 4 years ago
parent c693e9a109
commit aeb289fce6

@ -10,12 +10,10 @@ class Path extends BodyComponent {
required List<List<Vector2>> paths, required List<List<Vector2>> paths,
}) : _position = position, }) : _position = position,
_paths = paths { _paths = paths {
if (color != null) {
paint = Paint() paint = Paint()
..color = color ..color = color ?? const Color.fromARGB(0, 0, 0, 0)
..style = PaintingStyle.stroke; ..style = PaintingStyle.stroke;
} }
}
factory Path.straight({ factory Path.straight({
Color? color, Color? color,

@ -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_forge2d/flame_forge2d.dart';
import 'package:flame_test/flame_test.dart'; import 'package:flame_test/flame_test.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -15,7 +15,7 @@ void main() {
group('straight', () { group('straight', () {
group('color', () { group('color', () {
flameTester.test( flameTester.test(
'has white color by default if not specified', 'has transparent color by default if not specified',
(game) async { (game) async {
final path = Path.straight( final path = Path.straight(
position: Vector2.zero(), position: Vector2.zero(),
@ -26,7 +26,10 @@ void main() {
await game.ensureAdd(path); await game.ensureAdd(path);
expect(game.contains(path), isTrue); expect(game.contains(path), isTrue);
expect(path.paint, isNotNull); expect(path.paint, isNotNull);
expect(path.paint.color, equals(Colors.white)); expect(
path.paint.color,
equals(Color.fromARGB(0, 0, 0, 0)),
);
}, },
); );
flameTester.test( flameTester.test(

Loading…
Cancel
Save