I have 3 section in my page Blue green and red Section
what i want is how to make the red section scrollable meanwhile the other section will stuck in place
Here is my Widget Tree
Container(
child: Stack(
alignment: Alignment.topCenter,
children: [
Column(
children: [
Container(
height: size.height * .12,
decoration: BoxDecoration(color: kPrimaryColor),
),
Container(
height: size.height * .12,
decoration: BoxDecoration(color: Colors.green),
),
// I want this part to be scrollable
Column(
children: [
Container(
height: size.height * 2,
color: Colors.red,
),
],
)
],
),
Positioned(
top: size.height * .12 - 45,
child: ClipRRect(
borderRadius: BorderRadius.circular(360),
child: Container(
height: 90,
width: 90,
padding: EdgeInsets.all(5),
decoration: BoxDecoration(
shape: BoxShape.circle, color: Colors.green),
child: ClipRRect(
borderRadius: BorderRadius.circular(360),
child: Image.network(defualtImage, fit: BoxFit.cover)),
),
)),
],
),
);
I have tried wrapping my red Column
widget with SingeChildScrollView
and NestedScrollView
but nothing seems to work.
Wrap your 3rd Column
widget that you want scrollable with SingleChildScrollView
+ Expanded
widget.
Expanded(
child: SingleChildScrollView(child: Your 3rd column widget with Red background container),
),
Wow it was that easy, thanks i still don't understand how these widget behave in flutter.
Basically you are having one Column, and inside that 3 Other widgets. Expanded tells to take max height (in case of Column widget), and SingleChildScrollView makes it scrollable!
but how about wrapping the Column widget with a Container and setting it's height to double.infinity will that work too?
It won't work because Column can't have infinite viewport.. So you can't specify infinite height for the column.