如何解决使用 TextField 和 DropdownButton
我有带有 TextField 和 DropDownButton 的 AlertDilaog。
问题:
一旦我启动对话框并单击文本字段,警报对话框就会向上移动,并且文本字段中的标签动画就会发生。但是在发生这种情况时我看到了卡顿。 我做了分析,我仍在努力了解它发生的原因。
这里是分析文件:https://filebin.net/7wulbm9j88m6jjt3
谁能帮我理解这个 VsyncProcessCallback 是什么以及所选部分(括号)中发生的任何事情?
我只是想找出 Jank 的根本原因并将其删除。
提前致谢。
TextField 代码:
Widget _addProtocolTextField(BuildContext context) {
return Container(
height: 7.h,width: 70.w,child: TextField(
controller: _protocolNameController,style: TextStyle(
color: Theme.of(context).textColor,fontSize: 13.sp,),textAlign: TextAlign.left,maxLines: 1,decoration: Inputdecoration(
labelText: Strings.protocol_name_lable,labelStyle: TextStyle(color: ColorConstants.primaryColor),enabledBorder: _getBorder(),disabledBorder: _getBorder(),focusedBorder: _getBorder(),border: _getBorder(),);
}
OutlineInputBorder _getBorder() {
return OutlineInputBorder(
borderSide: BorderSide(color: ColorConstants.primaryColor),);
}
解决方法
这么多代码还不足以提供真正的解决方案,您可以参考以下提示:
- 不要制作带有功能的小部件,更喜欢根据您的要求制作单独的无状态或有状态小部件
- 您可以在发布版本上试试这个,看看它是否有帮助:https://flutter.dev/docs/perf/rendering/shader
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。