Skip to content

Commit 1cf8fcc

Browse files
SaadArdatiBirjuVachhani
authored andcommitted
🔧 Revert onChange & clean up event callbacks.
1 parent 3410d04 commit 1cf8fcc

File tree

2 files changed

+136
-275
lines changed

2 files changed

+136
-275
lines changed

packages/flutter_box_transform/example/lib/main.dart

Lines changed: 2 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -546,184 +546,13 @@ class _ImageBoxState extends State<ImageBox> {
546546
return Stack(
547547
fit: StackFit.expand,
548548
children: [
549-
// TODO: Remove
550-
if (model.clampingEnabled)
551-
Builder(
552-
builder: (context) {
553-
final rect = largestClampingBox;
554-
final line1 = extendLineToRect(
555-
model.clampingRect,
556-
rect.center.toVector2(),
557-
rect.bottomRight.toVector2(),
558-
);
559-
560-
final line2 = extendLineToRect(
561-
model.clampingRect,
562-
rect.center.toVector2(),
563-
rect.topRight.toVector2(),
564-
);
565-
566-
if (line1 == null || line2 == null) {
567-
return const SizedBox.shrink();
568-
}
569-
570-
return IgnorePointer(
571-
child: Stack(
572-
fit: StackFit.expand,
573-
children: [
574-
Positioned.fromRect(
575-
rect: rect,
576-
child: IgnorePointer(
577-
child: Container(
578-
color: Colors.yellow.withOpacity(0.2),
579-
child: Stack(
580-
fit: StackFit.expand,
581-
children: [
582-
const Placeholder(),
583-
Align(
584-
alignment: Alignment.center,
585-
child: Container(
586-
width: 15,
587-
height: 15,
588-
decoration: const BoxDecoration(
589-
color: Colors.blue,
590-
shape: BoxShape.circle,
591-
),
592-
),
593-
),
594-
Align(
595-
alignment: Alignment.topLeft,
596-
child: FractionalTranslation(
597-
translation: const Offset(-0.5, -0.5),
598-
child: Container(
599-
width: 20,
600-
height: 20,
601-
decoration: const BoxDecoration(
602-
color: Colors.blue,
603-
shape: BoxShape.circle,
604-
),
605-
),
606-
),
607-
),
608-
Align(
609-
alignment: Alignment.topRight,
610-
child: FractionalTranslation(
611-
translation: const Offset(0.5, -0.5),
612-
child: Container(
613-
width: 20,
614-
height: 20,
615-
decoration: const BoxDecoration(
616-
color: Colors.blue,
617-
shape: BoxShape.circle,
618-
),
619-
),
620-
),
621-
),
622-
Align(
623-
alignment: Alignment.bottomRight,
624-
child: FractionalTranslation(
625-
translation: const Offset(0.5, 0.5),
626-
child: Container(
627-
width: 20,
628-
height: 20,
629-
decoration: const BoxDecoration(
630-
color: Colors.blue,
631-
shape: BoxShape.circle,
632-
),
633-
),
634-
),
635-
),
636-
Align(
637-
alignment: Alignment.bottomLeft,
638-
child: FractionalTranslation(
639-
translation: const Offset(-0.5, 0.5),
640-
child: Container(
641-
width: 20,
642-
height: 20,
643-
decoration: const BoxDecoration(
644-
color: Colors.blue,
645-
shape: BoxShape.circle,
646-
),
647-
),
648-
),
649-
),
650-
],
651-
),
652-
),
653-
),
654-
),
655-
Positioned(
656-
left: line1[0].x,
657-
top: line1[0].y,
658-
child: FractionalTranslation(
659-
translation: const Offset(-0.5, -0.5),
660-
child: Container(
661-
width: 15,
662-
height: 15,
663-
decoration: BoxDecoration(
664-
color: Colors.red.withOpacity(1),
665-
shape: BoxShape.circle,
666-
),
667-
),
668-
),
669-
),
670-
Positioned(
671-
left: line2[0].x,
672-
top: line2[0].y,
673-
child: FractionalTranslation(
674-
translation: const Offset(-0.5, -0.5),
675-
child: Container(
676-
width: 15,
677-
height: 15,
678-
decoration: BoxDecoration(
679-
color: Colors.red.withOpacity(1),
680-
shape: BoxShape.circle,
681-
),
682-
),
683-
),
684-
),
685-
Positioned(
686-
left: line2[1].x,
687-
top: line2[1].y,
688-
child: FractionalTranslation(
689-
translation: const Offset(-0.5, -0.5),
690-
child: Container(
691-
width: 15,
692-
height: 15,
693-
decoration: BoxDecoration(
694-
color: Colors.red.withOpacity(1),
695-
shape: BoxShape.circle,
696-
),
697-
),
698-
),
699-
),
700-
Positioned(
701-
left: line1[1].x,
702-
top: line1[1].y,
703-
child: FractionalTranslation(
704-
translation: const Offset(-0.5, -0.5),
705-
child: Container(
706-
width: 15,
707-
height: 15,
708-
decoration: BoxDecoration(
709-
color: Colors.red.withOpacity(1),
710-
shape: BoxShape.circle,
711-
),
712-
),
713-
),
714-
),
715-
],
716-
),
717-
);
718-
},
719-
),
720549
TransformableBox(
721550
key: ValueKey('image-box-${box.name}'),
722551
rect: box.rect,
723552
flip: box.flip,
724553
clampingRect: model.clampingEnabled ? model.clampingRect : null,
725554
constraints: box.constraintsEnabled ? box.constraints : null,
726-
onChangeUpdate: (result, event) {
555+
onChange: (result, event) {
727556
widget.onChanged?.call(result);
728557
largestClampingBox = result.largestRect;
729558
setState(() {});
@@ -909,7 +738,7 @@ class _ClampingRectState extends State<ClampingRect> {
909738
flip: Flip.none,
910739
clampingRect: model.playgroundArea!,
911740
constraints: BoxConstraints(minWidth: minWidth, minHeight: minHeight),
912-
onChangeUpdate: (result, event) => model.setClampingRect(result.rect),
741+
onChange: (result, event) => model.setClampingRect(result.rect),
913742
onTerminalSizeReached: (
914743
bool reachedMinWidth,
915744
bool reachedMaxWidth,

0 commit comments

Comments
 (0)