Skip to content

unable to add GestureDetector to scrollable items #38

@lastmeta

Description

@lastmeta

say I scroll to a particular item. Then I tap it, well I can't tap it because if I put a GestureDetector on the item it will pick up the behavior and now I can't scroll.

so I can't have any behavior occur on the items if I want to use this package. for instance, I scroll to an item then tap it to enter it's details or edit or something. no. not going to happen. I have to click a button outside the scrolling widget, not a parent of the scrollable list or child in the item builder, but a button somewhere else.

am I wrong about this? is this a known limitation of the scroll_snap_list? or is there a very simple solution that I don't see?

for example:

GestureDetector(
      onTap: () {
        print('hitparents'); // never hits
      },
      child: Container(
          height: 70,
          width: screen.width * 2 / 3,
          alignment: Alignment.bottomCenter,
          child: ScrollSnapList(
              dispatchScrollNotifications: true,
              scrollPhysics: BouncingScrollPhysics(),
              listController: listScroll,
              selectedItemAnchor: SelectedItemAnchor.START,
              scrollDirection: Axis.horizontal,
              curve: Curves.easeInOutCubic,
              duration: 100,
              onItemFocus: (index) => setState(() {
                    print(index);
                    selectedIndex = index;
                  }),
              itemSize: screen.width / 3,
              itemCount: 107,
              itemBuilder: (buildContext, index) =>
                // unable to have a GestureDetector here or else I can't click on a item in the list to auto focus it... even if I set it to translucent. 
                  Container(
                    width: screen.width / 3,
                    padding: EdgeInsets.only(left: .25, bottom: 2),
                    alignment: Alignment.bottomCenter,
                    child: CircleImage(image: HypyrIcons.ad('ad').image),
                  ))))
]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions