From 871d5479419c1fdc4970b912a4362ddbee6c5e6d Mon Sep 17 00:00:00 2001 From: Gold872 Date: Sat, 16 Dec 2023 23:43:31 -0500 Subject: [PATCH] Fix widgets being draggable while resizing --- .../draggable_containers/draggable_widget_container.dart | 4 ++++ lib/widgets/tab_grid.dart | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/widgets/draggable_containers/draggable_widget_container.dart b/lib/widgets/draggable_containers/draggable_widget_container.dart index 4b23379b..89b1a911 100644 --- a/lib/widgets/draggable_containers/draggable_widget_container.dart +++ b/lib/widgets/draggable_containers/draggable_widget_container.dart @@ -244,6 +244,10 @@ class DraggableWidgetContainer extends StatelessWidget { rect: draggingRect, clampingRect: const Rect.fromLTWH(0, 0, double.infinity, double.infinity), + constraints: const BoxConstraints( + minWidth: 128.0, + minHeight: 128.0, + ), resizeModeResolver: () => ResizeMode.freeform, allowFlippingWhileResizing: false, handleTapSize: 12, diff --git a/lib/widgets/tab_grid.dart b/lib/widgets/tab_grid.dart index e510130c..db5620d3 100644 --- a/lib/widgets/tab_grid.dart +++ b/lib/widgets/tab_grid.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:flutter/material.dart'; import 'package:dot_cast/dot_cast.dart'; @@ -275,8 +277,8 @@ class TabGrid extends StatelessWidget { Rect preview = Rect.fromLTWH( previewX, previewY, previewWidth.toDouble(), previewHeight.toDouble()); - double newWidth = newRect.width.clamp(widget.minWidth, double.infinity); - double newHeight = newRect.height.clamp(widget.minHeight, double.infinity); + double newWidth = max(newRect.width, widget.minWidth); + double newHeight = max(newRect.height, widget.minHeight); widget.draggingRect = Rect.fromLTWH(newRect.left, newRect.top, newWidth, newHeight);