PR suggestions

This commit is contained in:
Erick Zanardo
2019-07-11 15:47:33 -03:00
committed by Erick
parent 138de02ae6
commit f415090c24
2 changed files with 17 additions and 43 deletions

View File

@ -1,30 +0,0 @@
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:debug/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}

View File

@ -104,6 +104,22 @@ abstract class PositionComponent extends Component {
return sqrt(pow(y - c.y, 2) + pow(x - c.x, 2)); return sqrt(pow(y - c.y, 2) + pow(x - c.x, 2));
} }
void renderDebugMode(Canvas canvas) {
canvas.drawRect(Rect.fromLTWH(0.0, 0.0, width, height), _debugPaint);
debugTextConfig.render(
canvas,
"x: ${x.toStringAsFixed(2)} y:${y.toStringAsFixed(2)}",
Position(-50, -15));
Rect rect = toRect();
final dx = rect.right;
final dy = rect.bottom;
debugTextConfig.render(
canvas,
"x:${dx.toStringAsFixed(2)} y:${dy.toStringAsFixed(2)}",
Position(width - 50, height));
}
void prepareCanvas(Canvas canvas) { void prepareCanvas(Canvas canvas) {
canvas.translate(x, y); canvas.translate(x, y);
@ -113,19 +129,7 @@ abstract class PositionComponent extends Component {
canvas.translate(dx, dy); canvas.translate(dx, dy);
if (debugMode) { if (debugMode) {
canvas.drawRect(Rect.fromLTWH(0.0, 0.0, width, height), _debugPaint); renderDebugMode(canvas);
debugTextConfig.render(
canvas,
"x: ${x.toStringAsFixed(2)} y:${y.toStringAsFixed(2)}",
Position(-50, -15));
Rect rect = toRect();
final dx = rect.right;
final dy = rect.bottom;
debugTextConfig.render(
canvas,
"x:${dx.toStringAsFixed(2)} y:${dy.toStringAsFixed(2)}",
Position(width - 50, height));
} }
} }
} }