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

flutter-使特定的小部件可滚动

(flutter - Make a specific Widget Scrollable)

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

我的页面中有3个部分蓝绿色和红色部分

我想要的是如何使红色部分可滚动,同时另一部分将卡在适当的位置

这是我的小部件树

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

我已经试过包装我的红色Column小部件SingeChildScrollViewNestedScrollView,但似乎没有任何工作。

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

ColumnSingleChildScrollView+Expanded小部件包装要滚动的第3个小部件。

Expanded(
  child: SingleChildScrollView(child: Your 3rd column widget with Red background container),
),