Search code examples
flutterdartflutter-layout

SingleChildScrollView still overflowing


I have a SingleChildScrollView inside of a Sized box. I thought this would make my page scrollable but it does not. I get this when I run it Overflow

I have the code

Container(
    width: double.infinity,
    alignment: Alignment.centerLeft,
    child: Column(
        children: [
            const SizedBox(
                width: double.infinity,
                child: some text
            ),
            const SizedBox(height: 10),
            SizedBox(
                    width: double.infinity,
                    child: SingleChildScrollView(
                        child: Column(
                            children: items
                                    .map((e) => ListTile(
                                                most recent items
                                            ))
                                    .toList(),
                        ),
                    )),
        ],
    ))

Solution

  • You need wrap your SizedBox with Expanded, so the SingleChildScrollView get available height in column, like this:

    Expanded(
      child: SizedBox(
          width: double.infinity,
          child: SingleChildScrollView(
            ...
          ),
      ),
    )