fix alignment for dot grid background + add clipping post canvas paint
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:infinite_lazy_grid/infinite_lazy_grid.dart';
|
||||
|
||||
import 'widgets/fps.dart';
|
||||
|
||||
class SimpleExample extends StatefulWidget {
|
||||
const SimpleExample({super.key});
|
||||
|
||||
@override
|
||||
State<SimpleExample> createState() => _SimpleExampleState();
|
||||
}
|
||||
|
||||
class _SimpleExampleState extends State<SimpleExample> {
|
||||
final LazyCanvasController controller = LazyCanvasController(debug: true);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
controller.addChild(
|
||||
Offset((i % 80) * 100.0, (i ~/ 80) * 100.0),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Tapped a container')));
|
||||
controller.focusOnChild(context, i);
|
||||
},
|
||||
child: InfoContainer(color: Colors.primaries[i % Colors.primaries.length]),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Simple Example')),
|
||||
floatingActionButton: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 8,
|
||||
children: [
|
||||
FloatingActionButton(
|
||||
heroTag: 'app_zoom_in',
|
||||
onPressed: () {
|
||||
controller.updateScalebyDelta(0.1);
|
||||
},
|
||||
child: const Icon(Icons.zoom_in),
|
||||
),
|
||||
FloatingActionButton(
|
||||
heroTag: 'app_zoom_out',
|
||||
onPressed: () {
|
||||
controller.updateScalebyDelta(-0.1);
|
||||
},
|
||||
child: const Icon(Icons.zoom_out),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Stack(
|
||||
children: [
|
||||
LazyCanvas(controller: controller, canvasBackground: SingleColorBackround(Colors.white)),
|
||||
Positioned(bottom: 64, left: 16, child: Fps()),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class InfoContainer extends StatelessWidget {
|
||||
final Color color;
|
||||
const InfoContainer({required this.color, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(color: color, width: 50, height: 50);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user