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


目录
相关文章
|
安全 数据安全/隐私保护 Android开发
Flutter应用程序加固的问题及解决方案
Flutter应用程序加固的问题及解决方案
260 0
Flutter-解决Try catch出现异常:type ‘_TypeError‘ is not a subtype of type ‘Exception‘ in type cast
Flutter-解决Try catch出现异常:type ‘_TypeError‘ is not a subtype of type ‘Exception‘ in type cast
293 1
|
5月前
|
机器学习/深度学习 JSON 自然语言处理
Flutter敏感词过滤实战:基于AC自动机的高效解决方案
在社交、直播等场景中,敏感词过滤至关重要。本文介绍基于AC自动机的Flutter高效敏感词过滤方案,通过构建Trie树与失败指针实现线性时间复杂度的多模式匹配,支持干扰字符处理与动态优化。代码实战结合性能对比,助你打造毫秒级响应的过滤系统,适用于聊天、评论、内容审核等场景,保障平台安全。
318 69
|
11月前
|
开发框架 移动开发 Android开发
安卓与iOS开发中的跨平台解决方案:Flutter入门
【9月更文挑战第30天】在移动应用开发的广阔舞台上,安卓和iOS两大操作系统各自占据半壁江山。开发者们常常面临着选择:是专注于单一平台深耕细作,还是寻找一种能够横跨两大系统的开发方案?Flutter,作为一种新兴的跨平台UI工具包,正以其现代、响应式的特点赢得开发者的青睐。本文将带你一探究竟,从Flutter的基础概念到实战应用,深入浅出地介绍这一技术的魅力所在。
246 7
|
Dart JavaScript 前端开发
Dart或Flutter中解决异常-type ‘int‘ is not a subtype of type ‘double‘
Dart或Flutter中解决异常-type ‘int‘ is not a subtype of type ‘double‘
419 4
|
Dart 前端开发 JavaScript
探索移动应用开发中的跨平台解决方案:Flutter与React Native的比较
在移动应用开发领域,选择合适的跨平台解决方案是关键。本文将深入分析Flutter和React Native这两大主流框架,从性能、开发效率、社区支持等方面进行比较,帮助开发者做出明智的选择。
250 27
|
存储 缓存 搜索推荐
Flutter开发者必读:sp_util - SharedPreferences的终极解决方案
Flutter开发者必读:sp_util - SharedPreferences的终极解决方案
239 0
|
机器学习/深度学习 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
522 0
|
安全 数据安全/隐私保护 Android开发
🚀Flutter应用程序加固的问题及解决方案
在移动应用开发中,为了保护应用程序的安全性,开发者需要对应用进行加固。在使用Flutter技术进行应用程序开发时,也需要注意应用程序的安全问题和加固方案。本文将介绍在Flutter应用程序加固过程中可能出现的问题,并提供相应的解决方案。通过学习本文,开发者可以更好地保护Flutter应用程序的安全性,提供更加安全的应用程序给用户使用。
Flutter特别耗性能的组建以及解决方案
Flutter 中使用起来耗性能的组件主要有以下几个: 1. 频繁重绘的组件,如 AnimatedBuilder、AnimatedContainer、AnimatedOpacity 和 AnimatedPositioned 等。 2. 布局复杂的组件,如 Table、Wrap 和 Flow 等,因为它们需要进行大量计算来确定子控件的位置和大小。
Flutter特别耗性能的组建以及解决方案