我正在使用InteractiveViewer显示视频。它工作正常。但我想设置初始缩放级别。
有什么办法吗?
return InteractiveViewer(
minScale: 1,
maxScale: 4,
constrained: false,
child: Container(
color: Colors.red,
width: 320,
height: 180,
child: widget.remoteVideoRenderer(),
),
);
2条答案
按热度按时间92vpleto1#
我能够做到这一点,并取得了不同程度的成功,就像这样(感谢@pskink为我指明了正确的方向):
viewTransformationController.value
是一个应用于视图的4x 4矩阵,它对平移/旋转/缩放进行编码。矩阵中这些变换的表示可能在某个地方有文档记录(和/或只是投影/仿射几何的标准),但我找不到它们,所以我只是在缩放/平移的同时打印出来,直到每个条目的作用变清楚。如果您只将缩放因子设置为2而不进行平移,则会放大小部件的左上角。
注意你不能使用
MediaQuery.of(context)
来访问initState()
方法中的窗口尺寸,这在你想放大窗口中间的时候会有些不方便,我还没有找到一个好的方法来做到这一点。nzk0hqpo2#
根据Amos Joshua的回答,如果你想一直放大屏幕中央,我有这个公式:
因此: