繁体   English   中英

在 Flutter 中创建可水平和垂直滚动的小部件

[英]Creating a widget that is both horizontally and vertically scrollable in Flutter

我想要一个可以同时水平和垂直滚动的小部件。 我会在其中放置比视口更大的小部件。 它可以是高度和宽度大于屏幕的容器。 例如,如果图像比屏幕大,我可以滚动它以查看顶部、左侧、底部和右侧部分,在此先感谢。

也许一个解决方案可能是将一个 listView 放在另一个 ListView 中并改变它的滚动方向......例如:

ListView(
   shrinkWrap: true,
   primary: true,
   children: <Widget>[
       ListView(
         shrinkWrap: true,
         primary: false,
         scrollDirection: Axis.horizontal,
         children: <Widget>[
            Container(
              width: MediaQuery.of(context).size.width*2,
              height: MediaQuery.of(context).size.height*2,
            ),
         ],
       )
     ],
   ),

没有测试,只是想帮助...

这听起来类似于: flutter 中的多向滚动

但也许以下插件可能是您想要的: https://pub.dev/packages/bidirectional_scroll_view

如果你想深入了解,这也在 Flutter 的 gitrepo 中进行了讨论: https://github.com/flutter/flutter/issues/20175

我不确定你为什么会想要这个,但在移动环境中拥有如此大的图像可能没有意义。 话虽如此,我可以想象它会在例如放大照片的情况下发生。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM