Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter keep certain elements fixed during scrolling?

How to keep some elements fixed (and above scrollable parts) during scroll? Does it need to be inside a SingleChildScrollView?

Made a visual example of my problem:

I need the blue part to be scrollable, and that it goes behind the green part that needs to stay fixed.

How to keep certain elements fixed during scrolling?

This is a simplified part of my code:

body: SingleChildScrollView(
          child: ListView(
            children: [
              Obx(()=>Container(THIS CONTAINER SHOULD STAY FIXED DURING SCROLL)),
              Obx(()=>Column(THIS PART SHOULD BE SCROLLABLE)),
              Obx(()=>Text(THIS PART SHOULD BE SCROLLABLE)),
              Obx(()=>Row(THIS PART SHOULD BE SCROLLABLE))
            ],
          )
        ),
like image 842
Gryva Avatar asked Oct 14 '25 08:10

Gryva


1 Answers

If you put your ListView widget and FixedContainer widget in a Column, it will work.

For example:

 Column(
    children: [
       Obx(()=>Container(THIS CONTAINER SHOULD STAY FIXED DURING SCROLL)),
       Expanded(
           child: ListView(
              Obx(()=>Column(THIS PART SHOULD BE SCROLLABLE)),
              Obx(()=>Text(THIS PART SHOULD BE SCROLLABLE)),
              Obx(()=>Row(THIS PART SHOULD BE SCROLLABLE)),
           ),
       ),
    ],
 )
like image 163
Eray Avatar answered Oct 17 '25 00:10

Eray



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!