最近在做项目时候发现, 一些复杂页面在跳转时候会卡跳转动画, 这个是由于在push的同事渲染复杂页面造成的(IOS原生没有这个问题)
解决办法: 延迟加载页面内容, 不知道有没有更好的解决办法, 有更好的办法请告诉我谢谢
body:refreshLoad ? widget.body: Container(),
在页面PUSH过程中body加载一个空的容器, 等待跳转完成再加载页面内容, 当然也可以用Futurebuilder方法来实现.
class LoaddingPageState extends State<LoaddingPage> {
bool refreshLoad = false;
@override
void initState() {
// TODO: implement initState
super.initState();
refresh();
}
@override
Widget build(BuildContext context) {
if (widget.autoLoad != null && widget.autoLoad == true) refreshLoad = true;
return WidgetUtils.simpleScaffold(
widget.title,
key: widget.key,
backgroundColor: widget.backgroundColor,
titleView: widget.titleView,
body:refreshLoad ? widget.body: Container(),
bottomWidget: widget.bottomWidget,
barBackgroundColor:widget.backgroundColor,
onBack: widget.onBack,
hideBar:refreshLoad ? widget.hideBar : true,
hideLeft:widget.hideLeft ?? false,
actions:widget.actions,
resizeToAvoidBottomInset:widget.resizeToAvoidBottomInset,
leftWidget:widget.leftWidget,
titleSpacing:widget.titleSpacing,
floatingActionButton:widget.floatingActionButton,
);
}
refresh(){
Future.delayed(const Duration(milliseconds: 500)).then((value) {
refreshLoad = true;
setState(() {
});
});
}
}
网友评论