flutter_box_transform library

Classes

AngularHandle
A handle that looks like corner/side brackets on a box.
AngularHandlePainter
A painter for the AngularHandle.
Box
An immutable, 2D, axis-aligned, floating-point rectangle whose coordinates are relative to a given origin.
BoxTransformer
A class that transforms a Box in several different supported forms.
Constraints
Holds a set of constraints to apply to any Dimension or Box.
DefaultCornerHandle
A circular handle in the corners of the box.
DefaultSideHandle
A rounded handle in the sides of the box.
Dimension
A 2D size with width and height.
MoveResult<B extends Object, V extends Object, D extends Object>
An object that represents the result of a move operation. Helps disambiguate between MoveResult and ResizeResult.
RectResult
An abstract class that represents the result of a transform operation.
ResizeResult<B extends Object, V extends Object, D extends Object>
An object that represents the result of a resize operation.
TransformableBox
A widget that allows you to resize and drag a box around a widget.
TransformableBoxController
A controller class that is used to control the TransformableBox widget.
TransformResult<B extends Object, V extends Object, D extends Object>
An object that represents the result of a transform operation. Could be resize or move or both.
UIBoxTransform
A Flutter translation of transform.BoxTransformer.

Enums

Flip
Represents the flip state of a rectangle, or, in other words, if the box is flipped horizontally, vertically, or diagonally.
HandleAlignment
Alignment of the handle.
HandlePosition
Represents a resizing handle on corners.
ResizeMode
Represents different types resizing modes. These are used to determine how the rect should be resized.

Extensions

BoxConstraitnsExt on BoxConstraints
Provides convenient methods for widgets.BoxConstraints.
BoxExt on Box
Provides convenient methods for Box.
ConstraintsExt on Constraints
Provides convenient methods for Constraints.
DimensionExt on Dimension
Provides convenient methods for Dimension.
MoveResultExt on RawMoveResult
Provides convenient methods for RawMoveResult.
RawTransformResultExt on RawTransformResult
Provides convenient getters for TransformResult.
RectExt on Rect
Provides convenient methods for Rect.
ResizeResultExt on RawResizeResult
Provides convenient methods for RawResizeResult.
SizeExt on Size
Provides convenient methods for Size.
UITransformResultExt on UITransformResult
Provides convenient getters for UITransformResult.
UIVector2Ext on Offset
Provides convenient methods for Offset.
Vector2Ext on Vector2
Provides convenient methods for Vector2.

Constants

kDefaultHandleBorderWidth → const double
Default width of the border of the handles.

Functions

constrainAvailableAreaForScaling({required Box area, required Box initialRect, required HandlePosition handle, required Constraints constraints}) Box
Constrains available area for ResizeMode.scale.
defaultResizeModeResolver() ResizeMode
Default ResizeModeResolver implementation. This implementation doesn't rely on the focus system .It resolves the ResizeMode based on the pressed keys on the keyboard from the WidgetsBinding.keyboard.logicalKeysPressed hence it only works on hardware keyboards.
extendLinePointsToRectPoints(double left, double top, double right, double bottom, double x1, double y1, double x2, double y2) → (double, double, double, double)?
Extends given line to the given rectangle such that it touches the rectangle points.
extendLineToRect(Box rect, Vector2 p1, Vector2 p2) → (Vector2, Vector2)?
Extends given line to the given rectangle such that it touches the rectangle.
findLineIntersection(Vector2 inner, Vector2 outer, Box rect, Box initialRect) Map<HandlePosition, Vector2>
Finds the intersection between the given line and the given rectangle and returns distance between the intersection and the inner point.
flipRect(Box rect, Flip flip, HandlePosition handle) Box
Flips the given rect with given flip with handle being the pivot point.
getAvailableAreaForHandle({required Box rect, required Box clampingRect, required HandlePosition handle, Constraints constraints = const Constraints.unconstrained()}) Box
Returns the available area for the given handle.
getClampingRectForCornerHandle({required Box initialRect, required Box availableArea, required HandlePosition handle}) Box
Returns the clamping rect for the given corner handle for ResizeMode.scale.
getClampingRectForHandle({required Box initialRect, required Box availableArea, required HandlePosition handle}) Box
Returns the clamping rect for the given handle for ResizeMode.scale.
getClampingRectForSideHandle({required Box initialRect, required Box availableArea, required HandlePosition handle}) Box
Returns a clamping rect for given side handle that preserves aspect ratio.
getClosestEdge(Box initialRect, Box clampingRect, {HandlePosition? excludeHandle}) HandlePosition
Returns the handle/edge of the initialRect that is closest to one of the edge of clampingRect for ResizeMode.scale.
getFlipForRect(Box rect, Vector2 localPosition, HandlePosition handle, ResizeMode resizeMode) Flip
Calculates flip state of the given rect w.r.t localPosition and handle. It uses handle and localPosition to determine the quadrant of the rect and then checks if the rect is flipped in that quadrant.
getMinRectForScaling({required Box initialRect, required HandlePosition handle, required Constraints constraints}) Box
Returns a minimum Rect for given constraints when ResizeMode.scale.
intersectionBetweenRects({required Box outerRect, required Box innerRect, HandlePosition? excludeHandle}) HandlePosition
Returns the intersection between the given rectangles with assumption that innerRect is completely inside outerRect. The intersection is calculated using the center of the innerRect and the corners of the outerRect. Returns the closest edge/handle of outerRect to the innerRect.
intersectionBetweenTwoLines(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4) → Vector2?
Returns a vector of the point of intersection between two given lines. First two vectors p1 and p2 are the first line, and the second two vectors p3 and p4 are the second line.
isValidRect(Box rect, Constraints constraints, Box clampingRect) bool
returns whether the given rect is properly confined within its constraints but at the same time is not outside of the clampingRect.
scaledSymmetricClampingRect(Box initialRect, Box clampingRect) Box
Returns a clamping rect for ResizeMode.scaledSymmetric.

Typedefs

HandleBuilder = Widget Function(BuildContext context, HandlePosition handle)
A callback that expects a Widget that represents any of the handles. The handle is the current position and size of the handle.
RawMoveResult = MoveResult<Box, Vector2, Dimension>
A convenient typedef for TransformResult with Box, Vector2, and Dimension as the generic types that is used by BoxTransformer.
RawResizeResult = ResizeResult<Box, Vector2, Dimension>
A convenient typedef for TransformResult with Box, Vector2, and Dimension as the generic types that is used by BoxTransformer.
RawTransformResult = TransformResult<Box, Vector2, Dimension>
A convenient typedef for TransformResult with Box, Vector2, and Dimension as the generic types that is used by BoxTransformer.
RectChangeEvent = void Function(UITransformResult result, DragUpdateDetails event)
A callback that is called when the box is moved or resized.
RectDragCancelEvent = void Function()
A callback that is called when the box cancels a drag operation.
RectDragEndEvent = void Function(DragEndDetails event)
A callback that is called when the box ends a drag operation.
RectDragStartEvent = void Function(DragStartDetails event)
A callback that is called when the box begins a drag operation.
RectDragUpdateEvent = void Function(UIMoveResult result, DragUpdateDetails event)
A callback that is called when the box is being dragged.
RectResizeCancel = void Function(HandlePosition handle)
A callback that is called when the box cancels a resize operation.
RectResizeEnd = void Function(HandlePosition handle, DragEndDetails event)
A callback that is called when the box ends a resize operation.
RectResizeStart = void Function(HandlePosition handle, DragStartDetails event)
A callback that is called when the box begins a resize operation.
RectResizeUpdateEvent = void Function(UIResizeResult result, DragUpdateDetails event)
A callback that is called when the box is being resized.
TerminalAxisEvent = void Function(bool reachedMin, bool reachedMax)
A callback that is called when the box reaches a minimum or maximum size when resizing a specific axis.
TerminalEdgeEvent = void Function(bool reached)
A callback that is called when the box reaches a terminal edge when resizing.
TerminalEvent = void Function(bool reachedMinWidth, bool reachedMaxWidth, bool reachedMinHeight, bool reachedMaxHeight)
A callback that is called when the box reaches a minimum or maximum size when resizing.
TransformableChildBuilder = Widget Function(BuildContext context, Rect rect, Flip flip)
A callback that expects a Widget that represents the content of the box. The rect is the current position and size of the box. The flip is the current flip state of the box.
UIMoveResult = MoveResult<Rect, Offset, Size>
A convenient type alias for a ResizeResult with Flutter's Rect, Offset and Size types.
UIResizeResult = ResizeResult<Rect, Offset, Size>
A convenient type alias for a MoveResult with Flutter's Rect, Offset and Size types.
UITransformResult = TransformResult<Rect, Offset, Size>
A convenient type alias for a TransformResult with Flutter's Rect, Offset and Size types.