
正文
flutter溢出隐藏,flutter隐藏组件
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
【Flutter】图片、内容、滚动空间溢出调整
空间超出提示
注释 :Flutter Incorrect use of ParentDataWidget
问题原因:Expanded、Flexible等组件,在“Container、Padding、Stack”组件中导致的。
解决方案:保持: Expanded、Flexible 只在 Row、Column 等组件内,不在其他组件内使用。
控件Row有一个水平的布局方向,但是内容已经超出了可显示的范围。
建议我们使用有弹性的控件比如Expanded代替,或者使用可裁剪的控件ClipRect代替,还可以使用具体滚动属性的控件比如ListView代替
1、类似图片加载失败,然后溢出挤压空间,可以用Container包裹一下
直接使用,如果图片地址失效,就会溢出
直接使用,图片链接失效引起
2、类似这种超出
A RenderFlex overflowed by 48 pixels on the right.
3、类似这种Column滚动超出!
实现页面滑动需要用到SingleChildScrollView组件,SingleChildScrollView和Android中ScrollView类似
问题原因:Expanded、Flexible等组件,在“Container、Padding、Stack”组件中导致的。
解决方案:保持:Expanded、Flexible只在Row、Column等组件内,不在其他组件内使用。
相关问答
Q1: Flutter Row Column 布局溢出的问题
大家在学习Flutter的时候,刚刚开始学习布局应该会各种遇到溢出。比如在用到Row或者Column经常会遇到布局溢出的问题。
Consider applying a flex factor (e.g. 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.
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.
SingleChildScrollView和Expanded做为布局防止布局溢出
Q2: Flutter - 显示/隐藏控件的几种方法
实际效果,不会占位,隐藏时 TestWidget 不会加载,可 else 一个占位(则会加载占位的组件)
实际效果,会占位,显示隐藏TestWidget都会加载
实际效果,不会占位,显示隐藏TestWidget都会加载
实际效果,可选择是否占位,不占位,隐藏时TestWidget不会加载,占位,显示隐藏TestWidget都会加载
Visibility 选择占位时,隐藏 TestWidget







