Flutter Interactive Viewer 显示图像的缩小版本

him*_*shp 5 dart flutter

所以我尝试实现交互式小部件,滚动、放大和缩小工作正常。但是在初始渲染时我遇到了问题,它显示了放大的图像。我想要显示什么,以便整个图像可见并且用户可以交互。这是我的代码。一点点谷歌搜索告诉我我们可以使用matrix4identity或toScene方法实现相同的目的,这超出了我的技能范围,有人可以在这里提供帮助吗?

InteractiveViewer(
  transformationController: mapController,
  minScale: 0.1,
  maxScale: 1.5,
  constrained: false,
  // scaleEnabled: false,
  child: Image.network(
      'https://images.unsplash.com/photo-1502920514313-52581002a659'),
)
Run Code Online (Sandbox Code Playgroud)

这里放大了在初始渲染上显示的图像,我想要的是第一个选项,我可以在其中至少看到图像的某些部分,以便它对用户有意义。 https://ibb.co/HYnZBvG(期望结果) https://ibb.co/xg0nxnH(实际结果)

ris*_*try 0

这是因为您没有为 Image Widget 提供任何适合参数,只是提供 BoxFit.fitWidth 来渲染相对于宽度的图像或 BoxFit.fitHeight 来渲染相对于高度的图像,并尝试将约束设置为 true

InteractiveViewer(
  transformationController: mapController,
  minScale: 0.1,
  maxScale: 1.5,
  constrained: false,
  // scaleEnabled: false,
   child: Image.network(
   'https://images.unsplash.com/photo- 
    15029205143152581002a659',fit:BoxFit.fitWidth,
    ),
)
Run Code Online (Sandbox Code Playgroud)