首页 > 解决方案 > Flutter:从列表视图中滚动排除一个对象

问题描述

我有一个对象列表视图,其中基本上包含一个带有文本字段的表单、一个谷歌地图对象,然后是另一种形式的复选框。

我想做的是让谷歌地图对象不是整个列表视图的滚动物理的一部分,因为那样你实际上根本无法移动地图。

一些代码:

构建小部件内的构造函数:

Flexible(
  child: StreamBuilder(
    stream: Firestore.instance.collection('users').document(uid).snapshots(),
    builder: (BuildContext context, AsyncSnapshot<DocumentSnapshot> snapshot) {
      if (snapshot.hasData) {
        return ListView.builder(
          physics: ScrollPhysics(),
          shrinkWrap: true,
          itemCount: 1,
          itemBuilder: (context, index) =>
           _buildListRows(context, snapshot.data),
        );
        } else {
          return LoadingAnimation();
        }
      },
    ),
  ),

_buildListRows 小部件,简化:

Widget _buildListRows(BuildContext context, DocumentSnapshot document) {
  return Container(
    child: Form(
        child: Column(
        children: <Widget>[
          Container(
            child: TextFormField(),
          ),
          Container(
            child: SizedBox(
              child: GoogleMap(),
            ),
          ),
          Expanded(
            Container(
              ListView(
                physics: ScrollPhysics(),
                children: keys.map(key) {
                  return Checkbox(value: key);
                }
            ),
          ),
        ],
      ),
    ),
  );
}

快速回顾一下,我需要能够滚动地图上方和下方的对象,以上下移动整个屏幕,但在地图本身上,我需要能够控制地图,以便触摸动作适用于取而代之的是地图功能。

我已经阅读了很多关于此的内容,并尝试了一些建议,例如在该父级下方设置一个单子滚动视图,然后是列表视图,但似乎我尝试的其他任何方法都完全破坏了应用程序,并且根本不会显示任何内容。

标签: google-mapsflutterlistview

解决方案


推荐阅读