skip to Main Content

I have a column where I want to put two ListViews like below

Column

  • ListView#1
  • ListView#2

I have added already ListView#1 and getting error when I try to add the ListVeiw#2 to the column. The error message is;

A Column cannot bet set to Scrollable when a child is set to Expanded

3

Answers


  1. The error you’re encountering is due to the fact that a Column with Expanded children is essentially an infinite Scrollable widget, and as a result, the Column widget itself cannot be made Scrollable.

    Here’s a simple solution: You can wrap your ListViews in a Flexible widget. The Flexible widget allows the child to have a flexible height. Here’s an example:

    Column:
        Flexible:
            child: ListView#1
        Flexible:
            child: ListView#2
    

    This will make each ListView have a flexible height, which allows them to be able to grow and shrink to fit the available space in the Column. As a result, the Column itself does not need to be made Scrollable.

    Login or Signup to reply.
  2. For both use inside your ListView use the below properties

    physics: const BouncingScrollPhysics(),
    shrinkWrap: true,
    

    You can also follow this tutorial

    Login or Signup to reply.
  3. You can try Expanded widget

    Column:
        Expanded:
            child: ListView#1
        Expanded:
            child: ListView#2
    

    What is the difference between the Expanded widget and the Flexible widget?

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