簡體   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