Flutter异常Another exception was thrown: A RenderFlex overflowed by 5.0 pixels on the bottom解决方案

简介: Flutter异常Another exception was thrown: A RenderFlex overflowed by 5.0 pixels on the bottom解决方案

异常信息

在使用SliverFixedExtentList展示菜单列表时程序抛出一下异常:

I/flutter (21190): ◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤
I/flutter (21190): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (21190): Another exception was thrown: A RenderFlex overflowed by 5.0 pixels on the bottom.
I/flutter (21190): Another exception was thrown: A RenderFlex overflowed by 5.0 pixels on the bottom.
I/flutter (21190): Another exception was thrown: A RenderFlex overflowed by 5.0 pixels on the bottom.
I/flutter (21190): Another exception was thrown: A RenderFlex overflowed by 5.0 pixels on the bottom.
I/flutter (21190): Another exception was thrown: A RenderFlex overflowed by 5.0 pixels on the bottom.
I/flutter (21190): Another exception was thrown: A RenderFlex overflowed by 5.0 pixels on the bottom.

并且在程序的页面上也同样无法正常显示:image.png

相关的代码如下:

SliverFixedExtentList(
          delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
            String title = titles[index];
            return Container(
              alignment: Alignment.centerLeft,
              child: InkWell(
                onTap: () {
                  print("this is the item of " + title);
                },
                child: Column(
                  children: <Widget>[
                    Padding(
                      padding: const EdgeInsets.all(15.0),
                      child: Row(
                        children: <Widget>[
                          Expanded(
                            child: Text(
                              title,
                              style: TextStyle(fontSize: 16.0),
                            ),
                          ),
                          rightArrowIcon
                        ],
                      ),
                    ),
                    Divider(
                      height: 1.0,
                    )
                  ],
                ),
              ),
            );
          }, childCount: titles.length),
          itemExtent: 50.0,
        )

异常原因及解决方法

经过尝试此问题的原因是因为padding值设置的大小超过了外层widget的高度。相关代码:


padding: const EdgeInsets.all(15.0),


根据异常可看出超过了5.0 pixels(像素),那么将padding的值改为12.5或小于12.5则异常解决:


padding: const EdgeInsets.all(12.5),

padding: const EdgeInsets.all(10.0),


目录
相关文章
|
3月前
|
安全 数据安全/隐私保护 Android开发
Flutter应用程序加固的问题及解决方案
Flutter应用程序加固的问题及解决方案
55 0
|
Android开发 Windows
【错误记录】Android Studio 的 Flutter 代码界面没有 Logcat 面板 ( 2021年08月28日最新解决方案 )(一)
【错误记录】Android Studio 的 Flutter 代码界面没有 Logcat 面板 ( 2021年08月28日最新解决方案 )(一)
220 0
【错误记录】Android Studio 的 Flutter 代码界面没有 Logcat 面板 ( 2021年08月28日最新解决方案 )(一)
|
3月前
|
机器学习/深度学习 Java Android开发
记录一个Flutter运行的异常FAILURE: Build failed with an exception. What went wrong: A problem occurred config
记录一个Flutter运行的异常FAILURE: Build failed with an exception. What went wrong: A problem occurred config
46 0
|
4月前
|
安全 数据安全/隐私保护 Android开发
🚀Flutter应用程序加固的问题及解决方案
在移动应用开发中,为了保护应用程序的安全性,开发者需要对应用进行加固。在使用Flutter技术进行应用程序开发时,也需要注意应用程序的安全问题和加固方案。本文将介绍在Flutter应用程序加固过程中可能出现的问题,并提供相应的解决方案。通过学习本文,开发者可以更好地保护Flutter应用程序的安全性,提供更加安全的应用程序给用户使用。
Flutter特别耗性能的组建以及解决方案
Flutter 中使用起来耗性能的组件主要有以下几个: 1. 频繁重绘的组件,如 AnimatedBuilder、AnimatedContainer、AnimatedOpacity 和 AnimatedPositioned 等。 2. 布局复杂的组件,如 Table、Wrap 和 Flow 等,因为它们需要进行大量计算来确定子控件的位置和大小。
Flutter特别耗性能的组建以及解决方案
|
开发工具
flutter | 悬浮窗解决方案 flutter_floating
flutter | 悬浮窗解决方案 flutter_floating
|
IDE 开发工具
Waiting for another flutter command to release the startup lock... 异常解决
平时我们在开发flutter过程中,在执行`flutter packages get`命令之后,如果运气不好的,命令没有执行成功的话,我们就会遇到这个错误提示: ``` Waiting for another flutter command to release the startup lock... ```
【Flutter框架】Flutter项目对于手势的运用以及单独指针、消歧问题的解决方案
【Flutter框架】Flutter项目对于手势的运用以及单独指针、消歧问题的解决方案
|
Dart JavaScript
[Flutter]足够入门的Dart语言系列之流程控制语句:中断和异常(continue/break、try...catch)
循环的执行是通过循环条件来控制的,但是,有时我们想要通过额外的条件判断,来决定是否中断执行,或者中断本次循环而继续执行下次及之后的循环;此外,我们需要对于异常情况的处理...
339 0
[Flutter]足够入门的Dart语言系列之流程控制语句:中断和异常(continue/break、try...catch)
|
API 开发工具 Android开发
【错误记录】Android Studio 的 Flutter 代码界面没有 Logcat 面板 ( 2021年08月28日最新解决方案 )(二)
【错误记录】Android Studio 的 Flutter 代码界面没有 Logcat 面板 ( 2021年08月28日最新解决方案 )(二)
290 0
【错误记录】Android Studio 的 Flutter 代码界面没有 Logcat 面板 ( 2021年08月28日最新解决方案 )(二)