add centering and focus capabilities
This commit is contained in:
@@ -15,9 +15,9 @@ class TestChild extends StatelessWidget {
|
||||
|
||||
void main() {
|
||||
testWidgets('CanvasView renders only visible children and reduces count on zoom out', (WidgetTester tester) async {
|
||||
final controller = CanvasController(debug: true, initialScale: 1);
|
||||
final controller = CanvasController(debug: true);
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
controller.addChild(Offset((i % 80) * 100.0, (i ~/ 80) * 100.0), () => TestChild(index: i));
|
||||
controller.addChild(Offset((i % 80) * 100.0, (i ~/ 80) * 100.0), (_) => TestChild(index: i));
|
||||
}
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -46,9 +46,9 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('CanvasView scales as expected', (WidgetTester tester) async {
|
||||
final controller = CanvasController(debug: true, initialScale: 1);
|
||||
controller.addChild(const Offset(0, 0), () => TestChild(index: 0));
|
||||
controller.addChild(const Offset(100, 100), () => TestChild(index: 1));
|
||||
final controller = CanvasController(debug: true);
|
||||
controller.addChild(const Offset(0, 0), (_) => TestChild(index: 0));
|
||||
controller.addChild(const Offset(100, 100), (_) => TestChild(index: 1));
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -57,6 +57,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final context = tester.element(find.byType(CanvasView));
|
||||
|
||||
// Initial size check
|
||||
final finder = find.byType(TestChild);
|
||||
@@ -67,7 +68,7 @@ void main() {
|
||||
controller.onScaleUpdate(ScaleUpdateDetails(focalPoint: const Offset(0, 0), scale: 2.0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.scale, 2.0);
|
||||
final ssPositions = controller.widgetsWithScreenPositions().map((e) => e.ssPosition).toList();
|
||||
final ssPositions = controller.widgetsWithScreenPositions(context).map((e) => e.ssPosition).toList();
|
||||
expect(ssPositions, [Offset.zero, const Offset(200, 200)]);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user