Warm tip: This article is reproduced from serverfault.com, please click

Make a specific Widget Scrollable

发布于 2020-11-27 16:26:25

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.

Questioner
Its YaaBoy
Viewed
0
3,143 2020-11-28 00:35:28

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),
),