diff --git a/doc/examples/debug/test/widget_test.dart b/doc/examples/debug/test/widget_test.dart deleted file mode 100644 index 37cbf14e9..000000000 --- a/doc/examples/debug/test/widget_test.dart +++ /dev/null @@ -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); - }); -} diff --git a/lib/components/component.dart b/lib/components/component.dart index 6513e434a..187e1f921 100644 --- a/lib/components/component.dart +++ b/lib/components/component.dart @@ -104,6 +104,22 @@ abstract class PositionComponent extends Component { 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) { canvas.translate(x, y); @@ -113,19 +129,7 @@ abstract class PositionComponent extends Component { canvas.translate(dx, dy); if (debugMode) { - 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)); + renderDebugMode(canvas); } } }