简体   繁体   中英

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

I would like to have a widget that can be scrolled both horizontally and vertically at the same time. I would place widgets in them that are larger that the viewport. It can be Container of height and width larger than that of the Screen. For eg if image is larger that screen the i can scroll it to view top, left, bottom and right parts Thanks in Advance.

Maybe a solution might be to put a listView inside another ListView and change its scrool direction... For example:

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,
            ),
         ],
       )
     ],
   ),

Not tested, just trying to help...

This sounds similar to: Multidirectional scroll in flutter

But maybe the following plugin might be what you want: https://pub.dev/packages/bidirectional_scroll_view

And if you want a deep dive, this is also being discussed in the gitrepo from Flutter: https://github.com/flutter/flutter/issues/20175

I am not sure why you would want this exactly, but it might not make sense having such a big image in a mobile context. That being said I can imagine it would happen in the context of, for example, a zoom into the photo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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