0

I have a ListView to display a list of Cards. When user clicks on card, the Details Page is called. To recognize the Tap gesture, I wrapped the CustomCard with the GestureDetector, but after this the List is not scrolling anymore.

class PageUI extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              SizedBox(height: 48),
              Text(
                'PageTitle',
                style: Get.theme.textTheme.headline5,
              ),
              SizedBox(height: 18),
              ListView.builder(
                  scrollDirection: Axis.vertical,
                  shrinkWrap: true,
                  itemCount: list.length,
                  itemBuilder: (context, index) => GestureDetector(
                    child: CustomCard(item: list[index]),
                    onTap: () {
                      // Navigate to DetailsPage
                    },
                  ),
                ),
            ],
          ),
        ),
    );
  }
}

1 Answer 1

4

Please try

ListView.builder(
              scrollDirection: Axis.vertical,
              shrinkWrap: true,
              physics: NeverScrollableScrollPhysics(),
              itemCount: 10,
              itemBuilder: (context, index) => GestureDetector(
                child: CustomCard(item: list[index]),
                onTap: () {
                  // Navigate to DetailsPage
                },
              ),
            ),
Sign up to request clarification or add additional context in comments.

1 Comment

Works really nice... solved my problem immediately

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.