获得徽章 24
🏆掘金签约作者 | 摸鱼王 @Android补全计划
#挑战每日一条沸点# 【Flutter-Bug小记】

问题描述:

showGeneralDialog() 中使用 TextField 组件,小键盘收起时,输入的内容会被清空。

问题原因:

不知道具体原因导致的 TextEditingController 对象重建

解决方法:

套一层,自定义一个 StatefulWidget,State 中定义持有一个 TextEditingController 实例
展开
coder_pig于2024-10-28 10:14发布的图片
评论
#挑战每日一条沸点# 【Flutter-Bug小记】[惊恐] 同事遇到的UI问题

问题描述:

【Expanded】控件在 Debug 模式显示正常,Release 模式直接不显示。

问题原因:

直接在 Container 中使用 Expanded 组件❗️ 而 Expanded、Flexible 组件只能在 Row、Column、Flex 中使用,🤷‍♀️ 其实在Debug模式也会抛出下述异常:

======== Exception caught by widgets library =======================================================
The following assertion was thrown while applying parent data.:
Incorrect use of ParentDataWidget.

The ParentDataWidget Expanded(flex: 1) wants to apply ParentData of type FlexParentData to a RenderObject, which has been set up to accept ParentData of incompatible type ParentData.

Usually, this means that the Expanded widget has the wrong ancestor RenderObjectWidget. Typically, Expanded widgets are placed directly inside Flex widgets.
The offending Expanded is currently placed inside a ColoredBox widget.

解法:

套个Row、Column、Flex 就好了,或者不用 Expanded 组件~[灵光一现]
展开
评论
下一页
个人成就
优秀创作者
文章被点赞 9,015
文章被阅读 981,784
掘力值 34,015
收藏集
7
关注标签
25
加入于