0

I have a listview of objects that contains basically a form with textfields, a google maps object and then another form of checkboxes.

What I would like to do is have the google maps object not part of the scroll physics of the listview as a whole, because then you cannot actually move the map around at all.

Some code:

Constructor inside the build widget:

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();
        }
      },
    ),
  ),

The _buildListRows Widget, simplified:

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

So a quick recap, I need to be able to scroll the objects above and below the map, to move the whole screen up and down, but on the map itself I need to be able to control the map, so that touch actions apply to map functionality instead.

I have read a lot about this and tried some of the suggestions like having a singlechildscrollview and then listviews underneath that parent but it seems anything else I try just completely breaks the app and nothing will display at all.

Bisclavret
  • 1,327
  • 9
  • 37
  • 65
  • I am not sure of any efficient way but you can have a listview(with shrink wrap), google map,2nd listview with shrink wrap. – Zeeshan Hussain Jul 30 '20 at 13:00
  • Does this answer your question? [How to avoid scrolling listview when scrolling in map within listview](https://stackoverflow.com/questions/56197268/how-to-avoid-scrolling-listview-when-scrolling-in-map-within-listview) – easeccy Jul 30 '20 at 13:14
  • Not sure why this question is being downvoted. If you are going to downvote, please add something useful or constructive as to why you are doing this. – Bisclavret Jul 30 '20 at 14:42
  • @Zeeshan, thank you friend. I thought the same thing myself, but when I try to split it all up like this is falls over and nothing will display. – Bisclavret Jul 30 '20 at 14:43
  • @easeccy, thank you very much for that link. It looked really promising, but it only sort of half works. If I use NeverScrollableScrollPhysics() on the parent ListView.builder, the map works great but then nothing will scroll at all. If I leave the parent with ScollPhysics() instead, it works so long as your first movement in the map is horizontal, as vertical movements still scroll the listview. You can move horizontal and initiate the map drag, and then you can move it around but it is untidy. – Bisclavret Jul 30 '20 at 14:45

0 Answers0