Skip to content

Commit e7b956f

Browse files
committed
[New] Added Drawing Example with imports fix
1 parent 456d766 commit e7b956f

2 files changed

Lines changed: 149 additions & 156 deletions

File tree

example/lib/main.dart

Lines changed: 147 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,7 @@ import 'package:flutter/material.dart';
77
import 'package:flutter/services.dart';
88
import 'package:google_fonts/google_fonts.dart';
99
import 'package:image_picker/image_picker.dart';
10-
import 'package:stack_board_plus/flutter_stack_board_plus.dart';
11-
import 'package:stack_board_plus/stack_board_plus_item.dart';
12-
import 'package:stack_board_plus/stack_case.dart';
13-
import 'package:stack_board_plus/stack_items.dart';
14-
import 'package:stack_board_plus/src/stack_board_plus_items/items/stack_draw_item.dart';
15-
import 'package:stack_board_plus/src/stack_board_plus_items/item_content/stack_draw_content.dart';
16-
import 'package:flutter_drawing_board/flutter_drawing_board.dart';
17-
import 'package:stack_board_plus/src/stack_board_plus_items/item_case/stack_draw_case.dart';
10+
import 'package:stack_board_plus/stack_board_plus.dart';
1811

1912
class ColorContent extends StackItemContent {
2013
ColorContent({required this.color});
@@ -630,12 +623,12 @@ class _HomePageState extends State<HomePage> {
630623
// Example using StackItemActionHelper for consistent styling
631624
return [
632625
// Duplicate button for text and drawing items
633-
if (item is StackTextItem || item is StackDrawItem)
634-
StackItemActionHelper.createDuplicateAction(
635-
item: item,
636-
context: context,
637-
onDuplicate: () => _duplicateItem(item),
638-
),
626+
// if (item is StackTextItem || item is StackDrawItem)
627+
// StackItemActionHelper.createDuplicateAction(
628+
// item: item,
629+
// context: context,
630+
// onDuplicate: () => _duplicateItem(item),
631+
// ),
639632

640633
// Drawing settings for drawing items
641634
if (item is StackDrawItem)
@@ -647,11 +640,11 @@ class _HomePageState extends State<HomePage> {
647640
),
648641

649642
// Lock/Unlock toggle
650-
StackItemActionHelper.createLockAction(
651-
item: item,
652-
context: context,
653-
onToggleLock: () => _toggleItemLock(item),
654-
),
643+
// StackItemActionHelper.createLockAction(
644+
// item: item,
645+
// context: context,
646+
// onToggleLock: () => _toggleItemLock(item),
647+
// ),
655648
];
656649
},
657650
),
@@ -2796,145 +2789,150 @@ Future<void> showDrawingSettingsDialog(BuildContext context, DrawingController c
27962789
child: Container(
27972790
width: 400,
27982791
padding: const EdgeInsets.all(16),
2799-
child: Column(
2800-
mainAxisSize: MainAxisSize.min,
2801-
crossAxisAlignment: CrossAxisAlignment.start,
2802-
children: [
2803-
// Header
2804-
Row(
2805-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
2806-
children: [
2807-
const Text('Drawing Tools', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
2808-
IconButton(
2809-
icon: const Icon(Icons.close),
2810-
onPressed: () => Navigator.of(context).pop(),
2811-
),
2812-
],
2813-
),
2814-
const Divider(),
2815-
2816-
// Package Methods Info
2817-
Container(
2818-
padding: const EdgeInsets.all(12),
2819-
decoration: BoxDecoration(
2820-
color: Colors.blue.withOpacity(0.1),
2821-
borderRadius: BorderRadius.circular(8),
2822-
border: Border.all(color: Colors.blue.withOpacity(0.3)),
2823-
),
2824-
child: Column(
2825-
crossAxisAlignment: CrossAxisAlignment.start,
2792+
child: SingleChildScrollView(
2793+
child: Column(
2794+
mainAxisSize: MainAxisSize.min,
2795+
crossAxisAlignment: CrossAxisAlignment.start,
2796+
children: [
2797+
// Header
2798+
Row(
2799+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
28262800
children: [
2827-
const Text('Available Package Methods:', style: TextStyle(fontWeight: FontWeight.bold)),
2828-
const SizedBox(height: 4),
2829-
const Text('• item.content!.undo() - Undo last action', style: TextStyle(fontSize: 12)),
2830-
const Text('• item.content!.redo() - Redo last action', style: TextStyle(fontSize: 12)),
2831-
const Text('• item.content!.clear() - Clear all drawing', style: TextStyle(fontSize: 12)),
2832-
const Text('• item.content!.getDrawingData() - Export data', style: TextStyle(fontSize: 12)),
2833-
const Text('• controller.setStyle() - Set drawing style', style: TextStyle(fontSize: 12)),
2801+
const Text('Drawing Tools', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
2802+
IconButton(
2803+
icon: const Icon(Icons.close),
2804+
onPressed: () => Navigator.of(context).pop(),
2805+
),
28342806
],
28352807
),
2836-
),
2837-
const SizedBox(height: 16),
2838-
2839-
// Drawing Actions
2840-
const Text('Actions', style: TextStyle(fontWeight: FontWeight.w600)),
2841-
const SizedBox(height: 8),
2842-
Row(
2843-
children: [
2844-
ElevatedButton.icon(
2845-
icon: const Icon(Icons.undo),
2846-
label: const Text('Undo'),
2847-
onPressed: () => controller.undo(),
2808+
const Divider(),
2809+
2810+
// Package Methods Info
2811+
Container(
2812+
padding: const EdgeInsets.all(12),
2813+
decoration: BoxDecoration(
2814+
color: Colors.blue.withOpacity(0.1),
2815+
borderRadius: BorderRadius.circular(8),
2816+
border: Border.all(color: Colors.blue.withOpacity(0.3)),
28482817
),
2849-
const SizedBox(width: 8),
2850-
ElevatedButton.icon(
2851-
icon: const Icon(Icons.redo),
2852-
label: const Text('Redo'),
2853-
onPressed: () => controller.redo(),
2818+
child: Column(
2819+
crossAxisAlignment: CrossAxisAlignment.start,
2820+
children: [
2821+
const Text('Available Package Methods:', style: TextStyle(fontWeight: FontWeight.bold)),
2822+
const SizedBox(height: 4),
2823+
const Text('• item.content!.undo() - Undo last action', style: TextStyle(fontSize: 12)),
2824+
const Text('• item.content!.redo() - Redo last action', style: TextStyle(fontSize: 12)),
2825+
const Text('• item.content!.clear() - Clear all drawing', style: TextStyle(fontSize: 12)),
2826+
const Text('• item.content!.getDrawingData() - Export data', style: TextStyle(fontSize: 12)),
2827+
const Text('• controller.setStyle() - Set drawing style', style: TextStyle(fontSize: 12)),
2828+
],
28542829
),
2855-
const SizedBox(width: 8),
2856-
ElevatedButton.icon(
2857-
icon: const Icon(Icons.clear_all),
2858-
label: const Text('Clear'),
2859-
onPressed: () => _showClearDrawingDialog(context, controller),
2860-
style: ElevatedButton.styleFrom(foregroundColor: Colors.red),
2830+
),
2831+
const SizedBox(height: 16),
2832+
2833+
// Drawing Actions
2834+
const Text('Actions', style: TextStyle(fontWeight: FontWeight.w600)),
2835+
const SizedBox(height: 8),
2836+
SingleChildScrollView(
2837+
scrollDirection: Axis.horizontal,
2838+
child: Row(
2839+
children: [
2840+
ElevatedButton.icon(
2841+
icon: const Icon(Icons.undo),
2842+
label: const Text('Undo'),
2843+
onPressed: () => controller.undo(),
2844+
),
2845+
const SizedBox(width: 8),
2846+
ElevatedButton.icon(
2847+
icon: const Icon(Icons.redo),
2848+
label: const Text('Redo'),
2849+
onPressed: () => controller.redo(),
2850+
),
2851+
const SizedBox(width: 8),
2852+
ElevatedButton.icon(
2853+
icon: const Icon(Icons.clear_all),
2854+
label: const Text('Clear'),
2855+
onPressed: () => _showClearDrawingDialog(context, controller),
2856+
style: ElevatedButton.styleFrom(foregroundColor: Colors.red),
2857+
),
2858+
],
28612859
),
2862-
],
2863-
),
2864-
const SizedBox(height: 16),
2865-
2866-
// Drawing Tools
2867-
const Text('Drawing Tools', style: TextStyle(fontWeight: FontWeight.w600)),
2868-
const SizedBox(height: 8),
2869-
const Text('Use the default drawing board tools or configure in the settings dialog.',
2870-
style: TextStyle(fontSize: 12, color: Colors.grey)),
2871-
const SizedBox(height: 16),
2872-
2873-
// Color Selection
2874-
const Text('Color', style: TextStyle(fontWeight: FontWeight.w600)),
2875-
const SizedBox(height: 8),
2876-
Wrap(
2877-
spacing: 8,
2878-
children: [
2879-
Colors.black, Colors.red, Colors.green, Colors.blue,
2880-
Colors.yellow, Colors.purple, Colors.orange, Colors.brown,
2881-
].map((color) => GestureDetector(
2882-
onTap: () {
2883-
selectedColor = color;
2884-
controller.setStyle(color: selectedColor);
2860+
),
2861+
const SizedBox(height: 16),
2862+
2863+
// Drawing Tools
2864+
const Text('Drawing Tools', style: TextStyle(fontWeight: FontWeight.w600)),
2865+
const SizedBox(height: 8),
2866+
const Text('Use the default drawing board tools or configure in the settings dialog.',
2867+
style: TextStyle(fontSize: 12, color: Colors.grey)),
2868+
const SizedBox(height: 16),
2869+
2870+
// Color Selection
2871+
const Text('Color', style: TextStyle(fontWeight: FontWeight.w600)),
2872+
const SizedBox(height: 8),
2873+
Wrap(
2874+
spacing: 8,
2875+
children: [
2876+
Colors.black, Colors.red, Colors.green, Colors.blue,
2877+
Colors.yellow, Colors.purple, Colors.orange, Colors.brown,
2878+
].map((color) => GestureDetector(
2879+
onTap: () {
2880+
selectedColor = color;
2881+
controller.setStyle(color: selectedColor);
2882+
setState(() {});
2883+
},
2884+
child: Container(
2885+
width: 32,
2886+
height: 32,
2887+
decoration: BoxDecoration(
2888+
color: color,
2889+
shape: BoxShape.circle,
2890+
border: Border.all(
2891+
color: selectedColor == color ? Colors.white : Colors.grey,
2892+
width: 2,
2893+
),
2894+
),
2895+
),
2896+
)).toList(),
2897+
),
2898+
const SizedBox(height: 16),
2899+
2900+
// Stroke Width
2901+
const Text('Stroke Width', style: TextStyle(fontWeight: FontWeight.w600)),
2902+
Slider(
2903+
min: 1,
2904+
max: 20,
2905+
value: strokeWidth,
2906+
divisions: 19,
2907+
label: strokeWidth.round().toString(),
2908+
onChanged: (value) {
2909+
strokeWidth = value;
2910+
controller.setStyle(strokeWidth: strokeWidth);
28852911
setState(() {});
28862912
},
2887-
child: Container(
2888-
width: 32,
2889-
height: 32,
2890-
decoration: BoxDecoration(
2891-
color: color,
2892-
shape: BoxShape.circle,
2893-
border: Border.all(
2894-
color: selectedColor == color ? Colors.white : Colors.grey,
2895-
width: 2,
2896-
),
2913+
),
2914+
const SizedBox(height: 16),
2915+
2916+
// Import/Export
2917+
const Text('Import/Export', style: TextStyle(fontWeight: FontWeight.w600)),
2918+
const SizedBox(height: 8),
2919+
Row(
2920+
children: [
2921+
ElevatedButton.icon(
2922+
icon: const Icon(Icons.save_alt),
2923+
label: const Text('Export'),
2924+
onPressed: () => _exportDrawing(context, controller),
28972925
),
2898-
),
2899-
)).toList(),
2900-
),
2901-
const SizedBox(height: 16),
2902-
2903-
// Stroke Width
2904-
const Text('Stroke Width', style: TextStyle(fontWeight: FontWeight.w600)),
2905-
Slider(
2906-
min: 1,
2907-
max: 20,
2908-
value: strokeWidth,
2909-
divisions: 19,
2910-
label: strokeWidth.round().toString(),
2911-
onChanged: (value) {
2912-
strokeWidth = value;
2913-
controller.setStyle(strokeWidth: strokeWidth);
2914-
setState(() {});
2915-
},
2916-
),
2917-
const SizedBox(height: 16),
2918-
2919-
// Import/Export
2920-
const Text('Import/Export', style: TextStyle(fontWeight: FontWeight.w600)),
2921-
const SizedBox(height: 8),
2922-
Row(
2923-
children: [
2924-
ElevatedButton.icon(
2925-
icon: const Icon(Icons.save_alt),
2926-
label: const Text('Export'),
2927-
onPressed: () => _exportDrawing(context, controller),
2928-
),
2929-
const SizedBox(width: 8),
2930-
ElevatedButton.icon(
2931-
icon: const Icon(Icons.upload_file),
2932-
label: const Text('Import'),
2933-
onPressed: () => _importDrawing(context, controller),
2934-
),
2935-
],
2936-
),
2937-
],
2926+
const SizedBox(width: 8),
2927+
ElevatedButton.icon(
2928+
icon: const Icon(Icons.upload_file),
2929+
label: const Text('Import'),
2930+
onPressed: () => _importDrawing(context, controller),
2931+
),
2932+
],
2933+
),
2934+
],
2935+
),
29382936
),
29392937
),
29402938
);

example/lib/shimmer_demo.dart

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/material.dart';
2-
import 'package:stack_board_plus/flutter_stack_board_plus.dart';
3-
import 'package:stack_board_plus/stack_items.dart';
2+
import 'package:stack_board_plus/stack_board_plus.dart';
43

54
class ShimmerDemo extends StatefulWidget {
65
const ShimmerDemo({Key? key}) : super(key: key);
@@ -140,11 +139,7 @@ class _ShimmerDemoState extends State<ShimmerDemo> {
140139
Text('2. Once images load, try dragging and moving them'),
141140
Text('3. The shimmer should NOT flicker during movement'),
142141
Text('4. Shimmer should only appear during initial loading'),
143-
SizedBox(height: 8),
144-
Text(
145-
'✅ Fixed: No shimmer flickering when moving loaded images',
146-
style: TextStyle(color: Colors.green, fontWeight: FontWeight.w500),
147-
),
142+
148143
],
149144
),
150145
),

0 commit comments

Comments
 (0)