You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an image starting in landscape mode, I rotate it 90 degrees, it then doesn't let me zoom out even though I have image spillover across every direction (top, bottom, left and right). It seems to be fixed at a certain zoom level.
I pretty much pulled the demo code from the example with some edits (passing a image path over to the stful widget):
import 'package:balln/const.dart';
import 'package:balln/utils/styled/style_scaffold.dart';
import 'package:crop/crop.dart';
import 'package:flutter/material.dart';
class Cropp extends StatefulWidget {
final String path;
Cropp(this.path);
@override
_CroppState createState() => _CroppState();
}
class _CroppState extends State<Cropp> {
final controller = CropController(aspectRatio: 3 / 4);
double _rotation = 0;
BoxShape shape = BoxShape.rectangle;
void _cropImage() async {
final pixelRatio = MediaQuery.of(context).devicePixelRatio;
final cropped = await controller.crop(pixelRatio: pixelRatio);
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return StyleScaffold(
appBar: AppBar(
title: Text('Crop Image'),
backgroundColor: appBarBackground,
// centerTitle: true,
actions: <Widget>[
IconButton(
onPressed: _cropImage,
tooltip: 'Crop',
icon: Icon(Icons.crop),
)
],
),
body: Column(
children: <Widget>[
Expanded(
child: Container(
color: Colors.black,
padding: EdgeInsets.all(8),
child: Crop(
onChanged: (decomposition) {
print(
"Scale : ${decomposition.scale}, Rotation: ${decomposition.rotation}, translation: ${decomposition.translation}");
},
controller: controller,
shape: shape,
child: Image.asset(widget.path,
fit: BoxFit.cover,
),
/* It's very important to set `fit: BoxFit.cover`.
Do NOT remove this line.
There are a lot of issues on github repo by people who remove this line and their image is not shown correctly.
*/
helper: shape == BoxShape.rectangle
? Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.white, width: 2),
),
)
: null,
),
),
),
Padding(
padding: EdgeInsets.only(bottom: 0),
child: Row(
children: <Widget>[
IconButton(
icon: Icon(Icons.undo),
tooltip: 'Undo',
onPressed: () {
controller.rotation = 0;
controller.scale = 1;
controller.offset = Offset.zero;
setState(() {
_rotation = 0;
});
},
),
Expanded(
child: SliderTheme(
data: theme.sliderTheme.copyWith(
trackShape: RectangularSliderTrackShape(),
),
child: Slider(
divisions: 8,
value: _rotation,
min: -180,
max: 180,
label: '$_rotation°',
onChanged: (n) {
setState(() {
_rotation = n.roundToDouble();
controller.rotation = _rotation;
});
},
),
),
),
],
),
),
],
),
);
}
}
```1
The text was updated successfully, but these errors were encountered:
It looks like there's some constraints across the background view (behind the aspect ratio box). I can pan left and right just fine but cannot pan up and down even though there is spillover in the up/down direction.
I'm trying to crop within a 4x3 aspect ratio.
I have an image starting in landscape mode, I rotate it 90 degrees, it then doesn't let me zoom out even though I have image spillover across every direction (top, bottom, left and right). It seems to be fixed at a certain zoom level.
I pretty much pulled the demo code from the example with some edits (passing a image path over to the stful widget):
The text was updated successfully, but these errors were encountered: