skip to Main Content
      child: Scaffold(
  body: SingleChildScrollView(
    child: Column(
      children: [
        _cardList(context),
        Column(
          children: [
            Expanded(
              child: ListView.builder(
                scrollDirection: Axis.vertical,
                shrinkWrap: true,
                itemCount: 3,
                itemBuilder: (context, index) {
                  return Card(
                    child: Image.asset('assets/images/horizontal.jpg'),
                  );
                },
              ),
            )
          ],
        ),

I created a list and added 3 images under each other. But I can’t scroll down. I thought because I did Column in Column. But nothing changed when I deleted the Bottom Column.

2

Answers


  1. Wrap your ListView with Expanded for better performance, instead of using shrinkWrap: true

    body: Column(
      children: [
        Expanded(
          child: ListView.builder(
            scrollDirection: Axis.vertical,
            itemCount: 3,
    
    Login or Signup to reply.
  2. you need to disable SingleChildScrollView scroll physic like this:

    SingleChildScrollView(
            physics: NeverScrollableScrollPhysics(),//<-- add this
            child: Column(
              children: [
                ListView.builder(
                  scrollDirection: Axis.vertical,
                  shrinkWrap: true,
                  itemCount: 3,
                  itemBuilder: (context, index) {
                    return Card(
                      child: Image.asset('assets/images/horizontal.jpg'),
                    );
                  },
                )
              ],
            ),
          ),
    

    both list are scroll vertically you need disable one of them which is SingleChildScrollView.

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