skip to Main Content

I’m trying to navigate (scroll) to the end of the page when I tap on my "DropdownButton2" to show all my items using:

scrollController.animateTo(
        scrollController.position.maxScrollExtent,
       duration: Duration(milliseconds: 40),
       curve: Curves.easeInOut,
);

The problem is that the "DropdownButton2" has no "onTapped" property, and wrapping it in "InkWell" or "GestureDetector" doesn’t respond to tapping but responds to other actions like long pressing.

Can someone help?

2

Answers


  1. Chosen as BEST ANSWER

    Using TapRegion() solves the issue.


    • Suggest wrapping the DropdownButton2 with a widget like GestureDetector or InkWell to detect taps. Explain that this will allow capturing the tap action, which can trigger the scrolling logic before or after interacting with the dropdown.

    • Recommend ensuring that the scroll controller logic is working correctly and tied to the scrollable widget (like a ListView or SingleChildScrollView).

    • Point out that the GestureDetector or InkWell needs to be carefully placed around the DropdownButton2 so that it doesn’t interfere with the dropdown functionality.

    • Emphasize testing to make sure the dropdown opens properly while also handling the scroll action.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search