Getting Started

Installation

Add this package to your dependencies in your pubspec.yaml file:

dart
  dependencies:
    flutter_box_transform: <latest_version>

or run following command in your project directory:

shell
  flutter pub add flutter_box_transform

Usage

Wrap the widget you want to resize or move with TransformableBox.

dart
Using TransformableBox inside a Stack
  Stack(
    children: [
      TransformableBox(
        rect: rect,
        flip: flip,
        onChanged: (event) {
          setState(() { // update the state
            box = event.rect;
            flip = event.flip;
          });
        },
        contentBuilder: (context, rect, flip) => Transform.scale(
          scaleX: flip.isHorizontal ? -1 : 1,
          scaleY: flip.isVertical ? -1 : 1,
          child: Image.asset( // your widget goes here.
            'assets/images/landscape.jpg',
            width: rect.width,
            height: rect.height,
            fit: BoxFit.fill,
          ),
        ),
      ),
    ],
  );

onChanged callback is called when user resizes or moves the box. You can use this callback to update the box by calling setState method explicitly.

On this page