I use this answer in my solution.
In order to implement dragging picture on an enlarged scale.
But in the original version, there was no increase in the picture using double-tap.
And I tried to make it myself. And it seems to me, something happened.
Here is my code:
class ZoomableWidget extends StatefulWidget {
final Widget child;
const ZoomableWidget({Key key, this.child}) : super(key: key);
@override
_ZoomableWidgetState createState() => _ZoomableWidgetState();
}
class _ZoomableWidgetState extends State<ZoomableWidget> {
Matrix4 matrix = Matrix4.identity();
Matrix4 zerada = Matrix4.identity();
bool zoomed = false;
@override
Widget build(BuildContext context) {
return GestureDetector(
onDoubleTap: (){
matrix.scale(!zoomed ? 2.0 : 1.0);
zoomed = !zoomed;
if (!zoomed) matrix = Matrix4.identity();
setState(() {
matrix = matrix;
});
},
child: MatrixGestureDetector(
shouldRotate: false,
shouldScale: true,
onMatrixUpdate: (Matrix4 m, Matrix4 tm, Matrix4 sm, Matrix4 rm) {
setState(() {
matrix = zoomed ? m : matrix;
});
},
child: Transform(
transform: matrix,
child: widget.child,
),
),
);
}
}
But immediately after the picture increased, she drove down. And when I start dragging image, the zoom is reset to the default value. Please tell me what should I do to fix my problem?