gpt4 book ai didi

flutter - 当交互式查看器是 Container 的子级时,交互式查看器缩放问题

转载 作者:行者123 更新时间:2023-12-05 01:10:41 26 4
gpt4 key购买 nike

我在交互式查看器中缩放图像,交互式查看器是容器的子项,为容器设置一些高度,缩放图像后,视口(viewport)中的特定位置,我无法滚动和缩放图像


class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';

@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: Zoom(),
),
);
}
}
class Zoom extends StatefulWidget
{
@override
MyStatelessWidget createState()=> MyStatelessWidget();
}
/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends State<Zoom> {


@override
Widget build(BuildContext context) {
return Center(
child:Container(height: 300,
child: InteractiveViewer(

scaleEnabled: true,maxScale: 4.0,
child: Center(
child:Container( child:Image.asset('Assets/Java-001.jpg',fit: BoxFit.cover,alignment: Alignment.center,)),
),
)));
}
}


我该如何解决这个问题?

最佳答案

尝试将这些参数添加到 InteractiveViewer 小部件:

minScale: 0.1,
maxScale: 4.0,
boundaryMargin: const EdgeInsets.all(double.infinity),
constrained: false,

关于flutter - 当交互式查看器是 Container 的子级时,交互式查看器缩放问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63902295/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com