简体   繁体   English

Flutter - A RenderFlex 在 showModalBottomSheet 底部溢出 190 像素

[英]Flutter - A RenderFlex overflowed by 190 pixels on the bottom in showModalBottomSheet

My showModalBottomSheet showing bottom overflow error: My Code of bottomSheet:我的 showModalBottomSheet 显示底部溢出错误:我的 bottomSheet 代码:

 loginSheet(BuildContext context) {
    return showModalBottomSheet(
        isScrollControlled: true,
        context: context,
        builder: (context) {
          return Padding(
            padding: EdgeInsets.only(
              bottom: MediaQuery.of(context).viewInsets.bottom,
            ),
            child: Container(
              height: MediaQuery.of(context).size.height * 0.30,
              width: MediaQuery.of(context).size.width,
              child: Column(
                children: [
                  Padding(
                    padding: EdgeInsets.symmetric(horizontal: 150.0),
                    child: Divider(
                      thickness: 4.0,
                      color: constantColors.whiteColor,
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.symmetric(horizontal: 10.0),
                    child: TextField(
                      controller: userEmailController,
                      decoration: InputDecoration(
                        hintText: 'Enter Email...',
                        hintStyle: TextStyle(
                          color: constantColors.whiteColor,
                          fontWeight: FontWeight.bold,
                          fontSize: 16.0,
                        ),
                      ),
                      style: TextStyle(
                        color: constantColors.whiteColor,
                        fontWeight: FontWeight.bold,
                        fontSize: 18.0,
                      ),
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.symmetric(horizontal: 10.0),
                    child: TextField(
                      controller: userPasswordController,
                      decoration: InputDecoration(
                        hintText: 'Enter Password...',
                        hintStyle: TextStyle(
                          color: constantColors.whiteColor,
                          fontWeight: FontWeight.bold,
                          fontSize: 16.0,
                        ),
                      ),
                      style: TextStyle(
                        color: constantColors.whiteColor,
                        fontWeight: FontWeight.bold,
                        fontSize: 18.0,
                      ),
                    ),
                  ),
                  FloatingActionButton(
                    backgroundColor: constantColors.blueColor,
                    child: Icon(
                      FontAwesomeIcons.check,
                      color: constantColors.whiteColor,
                    ),
                    onPressed: () {
                      if (userEmailController.text.isNotEmpty) {
                        Provider.of<Authentication>(context, listen: false)
                            .logIntoAccount(userEmailController.text,
                                userPasswordController.text)
                            .whenComplete(() => Navigator.pushReplacement(
                                context,
                                PageTransition(
                                    child: Homepage(),
                                    type: PageTransitionType.bottomToTop)));
                      } else {
                        warningText(context, 'Fill All the Data');
                      }
                    },
                  )
                ],
              ),
              decoration: BoxDecoration(
                  color: constantColors.blueGreyColor,
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(12.0),
                    topRight: Radius.circular(12.0),
                  )),
            ),
          );
        });
  }

Inspect Widget:检查小部件: 在此处输入图像描述

Error:错误:

A RenderFlex overflowed by 190 pixels on the bottom.一个 RenderFlex 在底部溢出了 190 个像素。

The relevant error-causing widget was Column lib\…\landingPage\landingHelpers.dart:188 You can inspect this widget using the 'Inspect Widget' button in the VS Code notification.相关的导致错误的小部件是 Column lib\...\landingPage\landingHelpers.dart:188 您可以使用 VS Code 通知中的“检查小部件”按钮检查此小部件。 The overflowing RenderFlex has an orientation of Axis.vertical.溢出的 RenderFlex 具有 Axis.vertical 的方向。 The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and black striped pattern.溢出的 RenderFlex 边缘已在渲染中用黄色和黑色条纹图案标记。 This is usually caused by the contents being too big for the RenderFlex.这通常是由于内容对于 RenderFlex 来说太大了。

Consider applying a flex factor (eg using an Expanded widget) to force the children of the RenderFlex to fit within the available space instead of being sized to their natural size.考虑应用弹性因子(例如,使用 Expanded 小部件)来强制 RenderFlex 的子级适应可用空间,而不是调整到它们的自然大小。 This is considered an error condition because it indicates that there is content that cannot be seen.这被认为是一种错误情况,因为它表明存在看不到的内容。 If the content is legitimately bigger than the available space, consider clipping it with a ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex, like a ListView.如果内容合法地大于可用空间,请考虑在将其放入 flex 之前使用 ClipRect 小部件对其进行剪辑,或者使用可滚动容器而不是 Flex,例如 ListView。

The specific RenderFlex in question is: RenderFlex#6aa4c OVERFLOWING有问题的具体 RenderFlex 是:RenderFlex#6aa4c OVERFLOWING

I Already Did this我已经这样做了

        isScrollControlled: true,

& &

padding: EdgeInsets.only(
              bottom: MediaQuery.of(context).viewInsets.bottom,
            ),

use SingleChildScrollView.使用 SingleChildScrollView。 wrap your padding with SingleChildScrollView用 SingleChildScrollView 包裹你的填充

Wrap the container in SingleChildScrollView :将容器包装在SingleChildScrollView中:

child: Container(
              height: MediaQuery.of(context).size.height * 0.30,
              width: MediaQuery.of(context).size.width,
              child: SingleChildScrollView(child: Column(

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM