You need to use a TransformationController to control InteractiveViewer.
Here is the code:
TransformationController _controller;
@override
void initState() {
_controller = TransformationController();
_controller.value = Matrix4.identity() * 0.5;
super.initState();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
height: 350,
child: InteractiveViewer(
transformationController: _controller,
minScale: .1,
maxScale: 1,
onInteractionEnd: (s) {
print(_controller.value);
},
constrained: false,
child: Stack(
children: [
Image.asset(
"assets/Big.Buck.Bunny.-.Landscape.png",
fit: BoxFit.fitWidth,
),
],
),
),
),
);
}
Please note that you may need to adjust initial scale value(the one multiplying with Matrix4) to get your desired output.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…