Search code examples
flutterdartflutter-layoutsinglechildscrollview

flutter scrollview and SingleChildScrollView throws bottom overflow and is not scrolling


The widgets inside the child scroll view doesn't scroll and throws bottom overflow exception on the screen when there are more widgets in that list view. I am not sure where I am doing a mistake.

home: Scaffold(
      body: Column(
          children: [
              APPbar(),
              Container(
                 color: Colors.grey[200],
                 child: Expanded(
                     child: Column(
                         children: [
                            searchBar(),
                            Row(children: casewidgets),
                         ], 
                     )
                 ),
              )
            
             SingleChildScrollView(
                child:Column(
                   children: [
                       Text("a new column"),
                       Text("a new column"),
                       Text("a new column"),
                       Text("a new column"),
                   ],
               )
             ),
        ]
)),

Solution

  • You can use Expanded on SingleChildScollView to get aviable height, and remove column's Expanded.

    home: Scaffold(
        body: Column(children: [
      // APPbar(),
      Container(
        color: Colors.grey[200],
        child: Column(
          children: [
            // searchBar(),
            Row(children: []),
          ],
        ),
      ),
      Expanded(
        child: SingleChildScrollView(
            child: Column(
          children: [
            for (int i = 0; i < 33; i++) Text("a new column"),
          ],
        )),
      ),
    ])),