我想让个人资料页面的一些信息可以滚动.对于布局,我使用堆栈作为父窗口小部件,并用定位窗口小部件填充它.我用所有位置参数填充了定位小部件,当我把它放在屏幕中间时,它允许我滚动它.似乎我越往下推小部件,滚动的区域就越小.直到这个区域消失.

最后一个定位的小部件是我想使其可滚动的小部件.我还把它和固定号码一起使用,但没用.

我是编程新手,所以我希望能把我的问题说清楚.提前谢谢你帮我.

这是我的代码:

    return Scaffold(
      appBar: AppBar(
        elevation: 2,
        leading: BackButton(onPressed: () {
          Navigator.pop(context,
              MaterialPageRoute(builder: (context) => eventHomeScreen()));
        }),
        backgroundColor: Colors.teal,
        title: Text('Leute', style: TextStyle(fontSize: 28)),
        actions: [
          IconButton(
            iconSize: 26,
            icon: Icon(Icons.chat),
            tooltip: 'Chat-Anfrage schicken',
            onPressed: () {
              Navigator.of(context).push(MaterialPageRoute(
                  builder: (context) => chatRequestSentScreen.withUser(user)));
            },
          )
        ],
      ),
      body: Stack(
        alignment: Alignment.bottomCenter,
        clipBehavior: Clip.none,
        children: <Widget>[
          Container(
            width: MediaQuery.of(context).size.width * 1,
            height: MediaQuery.of(context).size.height * .35,
            decoration: BoxDecoration(
              image: DecorationImage(
                image: user.getProfilePicture(),
                fit: BoxFit.cover,
              ),
            ),
          ),
          Positioned(
            bottom: -MediaQuery.of(context).size.height * 0.19,
            child: Card(
              color: Colors.teal.shade50,
              shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.only(
                topLeft: Radius.circular(40),
                topRight: Radius.circular(40),
              )),
              elevation: 0,
              child: Container(
                width: MediaQuery.of(context).size.width * 1,
                height: MediaQuery.of(context).size.height * 0.26,
                child: Column(
                  children: [
                    Text(
                      user.getFullName(),
                      style: TextStyle(
                        fontWeight: FontWeight.bold,
                        fontSize: 24,
                      ),
                    ),
                    Text(user.getCurrentAge().toString() + " Jahre",
                        style: TextStyle(
                          fontSize: 22,
                        )),
                    Text('Zuletzt aktiv: Heute',
                        style: TextStyle(
                          color: Colors.grey,
                          fontSize: 16,
                        )),
                    SizedBox(
                      height: 10,
                    ),
                    Container(
                      margin: EdgeInsets.symmetric(horizontal: 20),
                      padding:
                          EdgeInsets.symmetric(horizontal: 30, vertical: 5),
                      child: Text(user.getBio(),
                          maxLines: 3,
                          overflow: TextOverflow.ellipsis,
                          textAlign: TextAlign.center,
                          style: TextStyle(
                            fontSize: 20,
                          )),
                    ),
                    SizedBox(
                      height: 50,
                    ),
                  ],
                ),
              ),
            ),
          ),
          Positioned(
            top: MediaQuery.of(context).size.height * 0.45,
            left: 0.0,
            right: 0.0,
            bottom: -MediaQuery.of(context).size.height * 0.55,
            child: Container(
              decoration: BoxDecoration(
                  color: Colors.black87,
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(40),
                    topRight: Radius.circular(40),
                  )),
                width: MediaQuery.of(context).size.width * 1,
                height: MediaQuery.of(context).size.height * 0.4,
                child:
                Container(
                        margin: EdgeInsets.symmetric(horizontal: 20, vertical: 20),
                        padding:
                            EdgeInsets.symmetric(horizontal: 30, vertical: 5),
                        child: SingleChildScrollView(
                          physics: AlwaysScrollableScrollPhysics(),
                          child: Column(
                            children: SharedScreenFeatures.getSports(
                                user.getSports()),
                          ),
                        ),
                ),
              ),
            ),
        ],
      ),
    );
  }
}```

推荐答案

我解决了它,这花了我相当长的时间,但现在它完全符合我的目的.我仍在使用堆栈,但为了将内容向下推到需要的位置,我使用了一个透明容器.现在MediaQuery不再是负面的.也许不是完美的答案,但它是有效的.

return Scaffold(
  backgroundColor: Colors.teal.shade50,
  appBar: AppBar(
    elevation: 2,
    leading: BackButton(onPressed: () {
      Navigator.pop(context,
          MaterialPageRoute(builder: (context) => eventHomeScreen()));
    }),
    backgroundColor: Colors.teal,
    title: Text('Leute', style: TextStyle(fontSize: 28)),
    actions: [
      IconButton(
        iconSize: 26,
        icon: Icon(Icons.chat),
        tooltip: 'Chat-Anfrage schicken',
        onPressed: () {
          Navigator.of(context).push(MaterialPageRoute(
              builder: (context) => chatRequestSentScreen.withUser(user)));
        },
      )
    ],
  ),
  body: Stack(
    children: [
      Column(children: <Widget>[
          Container(
            height: MediaQuery.of(context).size.height * .33,
            decoration: BoxDecoration(
              image: DecorationImage(
                image: user.getProfilePicture(),
                fit: BoxFit.cover,
              ),
            ),
          ),
        ]),
      Positioned(
        top: MediaQuery.of(context).size.height * .27,
        child: Container(
          decoration: BoxDecoration(
              color: Colors.teal.shade50,
              borderRadius: BorderRadius.only(
                topLeft: Radius.circular(40),
                topRight: Radius.circular(40),
              )),
          width: MediaQuery.of(context).size.width * 1,
          child: Column(
            children: [
              Text(
                user.getFullName(),
                style: TextStyle(
                  fontWeight: FontWeight.bold,
                  fontSize: 24,
                ),
              ),
              Text(user.getCurrentAge().toString() + " Jahre",
                  style: TextStyle(
                    fontSize: 22,
                  )),
              Text('Zuletzt aktiv: Heute',
                  style: TextStyle(
                    color: Colors.grey,
                    fontSize: 16,
                  )),
            ],
          ),
        ),
      ),
      SingleChildScrollView(
        physics: NeverScrollableScrollPhysics(),
        child: Column(
          children: [
            Container(
              height: MediaQuery.of(context).size.height * .39,
              color: Colors.transparent,
            ),
            Container(
              height: MediaQuery.of(context).size.height * .15,
              width: MediaQuery.of(context).size.width * 1,
              color: Colors.teal.shade50,
              padding: EdgeInsets.symmetric(horizontal: 15, vertical: 0),
              child: SingleChildScrollView(
                physics: AlwaysScrollableScrollPhysics(),
                child: Text(
                   user.getBio(),
                  textAlign: TextAlign.center,
                  style: TextStyle(
                    fontSize: 20,
                  ),
                ),
              ),
            ),
            Container(
              height: MediaQuery.of(context).size.height * .4,
              width: MediaQuery.of(context).size.width *1 ,
              decoration: BoxDecoration(
                  color: Colors.black87,
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(40),
                    topRight: Radius.circular(40),
                  )),
              child: Container(
                margin: EdgeInsets.symmetric(horizontal: 20, vertical: 0),
                padding: EdgeInsets.symmetric(horizontal: 10, vertical: 20),
                child: SingleChildScrollView(
                  physics: AlwaysScrollableScrollPhysics(),
                  child: Column(
                    children:
                        SharedScreenFeatures.getSports(user.getSports()),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    ],
  ),
);

Flutter相关问答推荐

我如何才能收到每天重复的预定通知?

无法在主屏幕视图中设置当前日期容器'

为什么我的PUT请求不能正常工作?

使用ImageFilter模糊并剪裁同一renderObject中的元素

Android工作室Flutter 热重新加载更新后不工作

Flutter Android Google Sign-in error:ApiException:10在确认软件包名称、SHA-1 fingerprint 和设置同意页面后出现异常

请求已在 flutter 中发送到 django 服务器,并且已返回响应,但条件仍然为 false

打开键盘时屏幕组件会被压扁

如何使Flutter 边框宽度在外面而不是在里面?

Flutter Riverpod 对提供者状态的变化做出react

Flutter 中的区域不匹配

如何停止折线图的抖动

访问 AsyncSnapshot 中的嵌套属性

如何在 Flutter 中滚动时为多个小部件设置动画

更改文本字段Flutter 中最大字母的 colored颜色

在 flutter 中使用 StreamBuilder 在文本字段中键入时显示过滤记录

Flutter:font_awesome_icon pro 版报错?如何设置 font_awesome 克隆仓库的路径?

如何使用 Riverpod 在运行时动态创建提供程序?

如何从dart 中的当前日期时间中减go 1 天?

如何在 ElevatedButton 上设置背景 colored颜色 动画?