如何在Flutter中制作像Google Maps这样的可滚动小部件?

时间:2018-08-21 06:36:58

标签: dart scrollview flutter flutter-layout

我正在尝试创建一个可滚动的小部件,例如Google Maps,我可以将其向上滑动并查看整个小部件并将其滚动。但我无法使用滚动视图后面的小部件,而只能是带有背景地图的可滚动视图,我无法使用

直到现在我使用堆栈来具有可滚动区域并使用SingleChildScrollView小部件。

有没有办法用颤动做到这一点?

这是我脚手架的尸体

new Stack(
        children: <Widget>[
          new Flex(
            direction: Axis.vertical,
            children: <Widget>[new CustomMap()],
          ),
          new SingleChildScrollView(
            child: new Column(
              mainAxisSize: MainAxisSize.min,
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: <Widget>[
                new Container(
                  // A fixed-height child.
                  height: 520.0,
                ),
                new Container(
                  // Another fixed-height child.
                  color: Colors.green,
                  height: 820.0,
                ),
              ],
            ),
          )
        ],
      ),

2 个答案:

答案 0 :(得分:1)

我通过使用“ matrix_gesture_detector” (from here)

做到了

但还要使用在另一个线程中建议的一些小部件:

here由@pskink和@AawazGyawali

因此,首先您必须将“ matrix_gesture_detector”添加到“ dependencies”下的“ pubspec.yaml”中: matrix_gesture_detector:任意

将以下类复制并粘贴到lib文件夹下的新文件中(例如“ zoomable_widget.dart”) *来自此处:https://stackoverflow.com/a/57601929/7052552

code available on my repo

my result on youtube

enter image description here

答案 1 :(得分:0)

您要寻找持久性底纸吗?尝试执行以下操作:https://flutterdoc.com/bottom-sheets-in-flutter-ec05c90453e7