Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrollable Screen - Flutter

Tags:

flutter

dart

I'm trying to make my Main Screen fully scrollable, I've tried adding a SingleChildScrowView, a Column, wrap inside a ListView, but every single time there's some widget that throws an error or simply disappears, RenderFlex issues and etc. How could I make my screen scrollable, like a normal website?

Edit: My code is actually too big, but the body of my Scaffold is essentially like this:

Scaffold(
 body: SafeArea(
  child: Column(
   children: <Widget>[
    Container(
     child: ....
    ),
    Expanded(
     child: ....
    ),
   ]
  )
 )
);
like image 961
Juliano Portela Avatar asked May 03 '26 16:05

Juliano Portela


1 Answers

if you want to make a scrollable view then take a ListView Widget as Parent Widget and if you want to make some widgets with expanded vertically then use Column inside ListView or if you want to make Expanded in horizontal then take a Row widget see the code below and update accordingly as per your requirement, Hope the solution below helps you.

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
          child: Column(
            children: <Widget>[
              Expanded(
                child: ListView(
                  children: <Widget>[
                    Container(
                        color: Colors.amberAccent,
                        child: SizedBox(height: 400.0, width: MediaQuery.of(context).size.width,)
                    ),
                    Container(
                        color: Colors.indigo,
                        child: SizedBox(height: 400.0, width: MediaQuery.of(context).size.width,)
                    ),
                    Container(
                        color: Colors.amberAccent,
                        child: SizedBox(height: 400.0, width: MediaQuery.of(context).size.width,)
                    ),
                    Container(
                        color: Colors.indigo,
                        child: SizedBox(height: 400.0, width: MediaQuery.of(context).size.width,)
                    ),
                    Container(
                        color: Colors.amberAccent,
                        child: SizedBox(height: 400.0, width: MediaQuery.of(context).size.width,)
                    ),
                    Container(
                        color: Colors.indigo,
                        child: SizedBox(height: 400.0, width: MediaQuery.of(context).size.width,)
                    ),
                  ],
                ),
              ),
            ],
          )

      )
    );
  }

enter image description here

like image 149
Sanjeev Sangral Avatar answered May 07 '26 09:05

Sanjeev Sangral