imrpove readmes
This commit is contained in:
+6
-14
@@ -1,16 +1,8 @@
|
|||||||
# example
|
# Demos
|
||||||
|
|
||||||
A new Flutter project.
|
Contains 4 small focused demos.
|
||||||
|
|
||||||
## Getting Started
|
- `Simple Example` – minimal setup, add nodes, pan, zoom, focus.
|
||||||
|
- `Build Counts Example` – shows build / culling behavior; watch console for build counts.
|
||||||
This project is a starting point for a Flutter application.
|
- `Widget State Updates Example` – three patterns for dynamic / reactive child content.
|
||||||
|
- `Render Callbacks Example` – logs enter / exit render area callbacks and overlays debug info.
|
||||||
A few resources to get you started if this is your first Flutter project:
|
|
||||||
|
|
||||||
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
|
|
||||||
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
|
|
||||||
|
|
||||||
For help getting started with Flutter development, view the
|
|
||||||
[online documentation](https://docs.flutter.dev/), which offers tutorials,
|
|
||||||
samples, guidance on mobile development, and a full API reference.
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CachingTestApp extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _CachingTestAppState extends State<CachingTestApp> {
|
class _CachingTestAppState extends State<CachingTestApp> {
|
||||||
final LazyCanvasController controller = LazyCanvasController(debug: false);
|
final LazyCanvasController controller = LazyCanvasController(debug: false, buildCacheExtent: const Offset(50, 50));
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -34,7 +34,7 @@ class _CachingTestAppState extends State<CachingTestApp> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Widget Caching Test'),
|
title: const Text('Widget Build Counts'),
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -51,23 +51,7 @@ class _CachingTestAppState extends State<CachingTestApp> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: Column(
|
body: LazyCanvas(controller: controller),
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
color: Colors.yellow[100],
|
|
||||||
child: const Text(
|
|
||||||
'Instructions:\n'
|
|
||||||
'• Pan around the canvas - widgets should only build once initially\n'
|
|
||||||
'• Watch the console for build messages\n'
|
|
||||||
'• Use the refresh button to force rebuilds\n'
|
|
||||||
'• Zoom in/out to see caching in action',
|
|
||||||
style: TextStyle(fontSize: 12),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(child: LazyCanvas(controller: controller)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
floatingActionButton: Column(
|
floatingActionButton: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class DynamicWidgetExample extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _DynamicWidgetExampleState extends State<DynamicWidgetExample> {
|
class _DynamicWidgetExampleState extends State<DynamicWidgetExample> {
|
||||||
final LazyCanvasController controller = LazyCanvasController(debug: false);
|
final LazyCanvasController controller = LazyCanvasController(debug: false, buildCacheExtent: const Offset(50, 50));
|
||||||
|
|
||||||
// Store child IDs for later reference
|
// Store child IDs for later reference
|
||||||
late CanvasChildId selfManagedId;
|
late CanvasChildId selfManagedId;
|
||||||
@@ -93,16 +93,16 @@ class _DynamicWidgetExampleState extends State<DynamicWidgetExample> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: const Text('Dynamic Widget Inputs')),
|
appBar: AppBar(title: const Text('Widget State Updates')),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
color: Colors.grey[100],
|
color: Theme.of(context).colorScheme.surfaceContainerLowest,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const Text('Three approaches for dynamic inputs:', style: TextStyle(fontWeight: FontWeight.bold)),
|
const Text('Three approaches for state updates:', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
const Text('1. Self-managed StatefulWidget (left), loses state on unmount'),
|
const Text('1. Self-managed StatefulWidget (left), loses state on unmount'),
|
||||||
const Text('2. External data + updateChildWidget (center) - manual updates'),
|
const Text('2. External data + updateChildWidget (center) - manual updates'),
|
||||||
@@ -189,8 +189,6 @@ class ExternalDataWidget extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
debugPrint('ExternalDataWidget built with counter: $counter, key: $key');
|
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
width: 120,
|
width: 120,
|
||||||
height: 80,
|
height: 80,
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ void main() {
|
|||||||
runApp(
|
runApp(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
// showPerformanceOverlay: true,
|
// showPerformanceOverlay: true,
|
||||||
title: 'Infinite Lazy 2D Grid Example',
|
title: 'Infinite Lazy 2D Grid Examples',
|
||||||
home: const ExampleChooser(),
|
home: const ExampleChooser(),
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
|
theme: ThemeData(colorScheme: ColorScheme.fromSeed(seedColor: Color(0xffffbf69))),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -37,14 +38,14 @@ class ExampleChooser extends StatelessWidget {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => const CachingTestApp()));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => const CachingTestApp()));
|
||||||
},
|
},
|
||||||
child: const Text('Widget Caching Test'),
|
child: const Text('Widget Build Counts'),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => const DynamicWidgetExample()));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => const DynamicWidgetExample()));
|
||||||
},
|
},
|
||||||
child: const Text('Dynamic Widget Inputs'),
|
child: const Text('Widget State Updates'),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
@@ -59,7 +60,7 @@ class ExampleChooser extends StatelessWidget {
|
|||||||
child: Text(
|
child: Text(
|
||||||
'Examples:\n'
|
'Examples:\n'
|
||||||
'• Simple: Basic usage demo\n'
|
'• Simple: Basic usage demo\n'
|
||||||
'• Caching Test: To sanity check build counts\n'
|
'• Build Counts: To see what rebuilds when\n'
|
||||||
'• Dynamic Inputs: How to handle changing widget data\n'
|
'• Dynamic Inputs: How to handle changing widget data\n'
|
||||||
'• Render Callbacks: See widgets enter/exit render area',
|
'• Render Callbacks: See widgets enter/exit render area',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class _RenderCallbacksExampleState extends State<RenderCallbacksExample> {
|
|||||||
// Initialize controller with render callbacks
|
// Initialize controller with render callbacks
|
||||||
controller = LazyCanvasController(
|
controller = LazyCanvasController(
|
||||||
debug: true,
|
debug: true,
|
||||||
|
buildCacheExtent: const Offset(50, 50),
|
||||||
onWidgetEnteredRender: onWidgetEnteredRender,
|
onWidgetEnteredRender: onWidgetEnteredRender,
|
||||||
onWidgetExitedRender: onWidgetExitedRender,
|
onWidgetExitedRender: onWidgetExitedRender,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class SimpleExample extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SimpleExampleState extends State<SimpleExample> {
|
class _SimpleExampleState extends State<SimpleExample> {
|
||||||
final LazyCanvasController controller = LazyCanvasController(debug: true);
|
final LazyCanvasController controller = LazyCanvasController(debug: true, buildCacheExtent: const Offset(50, 50));
|
||||||
final List<CanvasChildId> childIds = [];
|
final List<CanvasChildId> childIds = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
Reference in New Issue
Block a user