image_crop icon indicating copy to clipboard operation
image_crop copied to clipboard

Let the grid static as a square, moving just the image

Open valksandro opened this issue 5 years ago • 6 comments

new behavior, let the grid as a perfect square and move just the image. Some apps have this behavior, like whatsApp for instance.

valksandro avatar Feb 14 '19 10:02 valksandro

Need too!

lubritto avatar Mar 13 '19 02:03 lubritto

I also want behavior like WhatsApp, The current behavior feels weird.

Thank you 🥇 By the way -> Nice package with a good performance

stefanschaller avatar Mar 27 '19 11:03 stefanschaller

@valksandro @lubritto

Use the crop function as below and thus you can fix the cropping behaviour square / rectangle

Crop.file( _sampleImage,
   key: cropKey,
   aspectRatio: widget.cropType == "square" ? 1.0 : 4.0/3.0,
),

VickySalunkhe avatar Apr 18 '19 16:04 VickySalunkhe

Does this really fix the issue? Because you can still move and scale the mask, but now it's just a square. I would prefer that you can only move the image in the background and not the scaling mask.

TimonBozzApps avatar May 03 '19 19:05 TimonBozzApps

Hey Fellas

I figured a way to do it, use a stack and put inside it a container with a thick border that basically overrides the grid , this way the image will only move and there's no way to move the grid or change its size because its overriden by a container Here's the code

```

Stack(

  children: <Widget>[


  Container(
    constraints: BoxConstraints.expand(
      height:300 ,
      width: 300,
    ),
    child :
    Crop.file(_sample, key: cropKey,
      scale : 2.0,
      aspectRatio:2,
      maximumScale : 2.0,
      alwaysShowGrid : false,
    ),
 ),
    Container(
      margin: EdgeInsets.symmetric(vertical: 70.0),
      decoration: BoxDecoration(
          border: Border.all(color: Colors.blueAccent, width: 12),
        //
      ),
      constraints: BoxConstraints.expand(
        height:170 ,
        width: 300,
      ),


    ),

)

mshenawy22 avatar Nov 17 '20 22:11 mshenawy22

@mshenawy22 this solution is not working because, container at the top of stack makes Crop widget untouchable even though it is transparent. Working solution is using stack again but not with container add just two lines at the top of image and the bottom. Here is the code;

Container(
      child: Stack(
        children: [
          AspectRatio(
            aspectRatio: 4 / 3,
            child: Crop.file(
              File(photos[0].path),
              key: singleCropKey,
              alwaysShowGrid: true,
              maximumScale: 4 / 3,
              aspectRatio: 4 / 3,
            ),
          ),
          Align(
            alignment: Alignment.topCenter,
            child: Container(
              width: double.infinity,
              height: 10,
              color: Colors.white,
            ),
          ),
          Align(
            alignment: Alignment.bottomCenter,
            child: Container(
              width: double.infinity,
              height: 10,
              color: Colors.white,
            ),
          ),
        ],
      ),
    )

burakcbdn avatar Jan 27 '21 13:01 burakcbdn