add scaling with hit test

This commit is contained in:
2025-07-05 16:41:43 +00:00
parent 3d41b56889
commit 7cfb9457a2
6 changed files with 177 additions and 75 deletions
+19 -1
View File
@@ -10,7 +10,7 @@ class App extends StatefulWidget {
}
class _AppState extends State<App> {
final CanvasController controller = CanvasController(debug: true);
final CanvasController controller = CanvasController(debug: true, initialScale: 1);
@override
void initState() {
@@ -24,6 +24,24 @@ class _AppState extends State<App> {
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: Column(
mainAxisSize: MainAxisSize.min,
spacing: 8,
children: [
FloatingActionButton(
onPressed: () {
controller.updateScalebyDelta(0.1);
},
child: const Icon(Icons.zoom_in),
),
FloatingActionButton(
onPressed: () {
controller.updateScalebyDelta(-0.1);
},
child: const Icon(Icons.zoom_out),
),
],
),
body: CanvasView(controller: controller, canvasBackground: SingleColorBackround(Colors.white)),
);
}
+8 -1
View File
@@ -2,5 +2,12 @@ import 'package:example/app.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(title: 'Infinite Lazy 2D Grid Example', home: const App(), debugShowCheckedModeBanner: false));
runApp(
MaterialApp(
// showPerformanceOverlay: true,
title: 'Infinite Lazy 2D Grid Example',
home: const App(),
debugShowCheckedModeBanner: false,
),
);
}