如何解决当交互式查看器是Container的子级时,交互式查看器缩放中的问题
我正在交互式查看器中缩放图像,交互式查看器是容器的子级,为容器设置一些高度,在缩放图像后,视口中的特定位置,我无法滚动和缩放图像
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小部件中:
scrollToDiv() {
document.getElementById('pricing').scrollIntoView({
behavior: 'smooth',})
var elements = document.getElementsByClassName('example-classname')
for(let e of elements) e.classList.add('glow')
var scrollTimeout
clearTimeout(scrollTimeout)
scrollTimeout = setTimeout(function () {
for(let e of elements) e.classList.remove('glow')
},2000)
}
,
如果您的小部件大于视口,您需要将 constrained
设置为 false
。
constrained:如果设置为false,则子项将被赋予无限约束。当孩子应该比 InteractiveViewer 大时,这通常很有用。
InteractiveViewer(
constrained: false,// Set it to false.
child: YourContainer(...),)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。