flutter_box_transform
library
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.
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.