当前位置: 首页 > news >正文

网站建设维护外包发帖效果好的网站

网站建设维护外包,发帖效果好的网站,宿州市埇桥区建设局网站,广17网站一起做网店在Flutter 实际开发过程中,页面数据往往是异步加载,接口请求回来后,数据刷新显示到界面上。 由于Flutter性能原因,也可能因为获取数据量比较大,在新页面路由进场动画执行过程中,接口请求结果回来了&#x…

在Flutter 实际开发过程中,页面数据往往是异步加载,接口请求回来后,数据刷新显示到界面上。

由于Flutter性能原因,也可能因为获取数据量比较大,在新页面路由进场动画执行过程中,接口请求结果回来了,很可能在进场动画执行过程中,刷新界面,导致进场动画卡顿。

那可不可以实现在路由进场完成后,再去请求数据,刷新界面呢,很遗憾官方没有类似的监听,官方提供的路由状态监听,是在调用push切换路由时,立即生效,和我们的期望不一致。

在查看了Flutter 源码,发现了一个取巧的方案,提供给大家。

直接上源码

/// @author bawomingtian
/// @date 2023/10/16
/// @desc 通过监听路由入场动画完成,判断路由完全进入,可以用来优化在进场动画执行过程中
/// 异步请求数据刷新界面,导致进场动画卡顿的问题
class AsyncState<T extends StatefulWidget> extends State<T> {Completer<bool> resumeCompleter = Completer();@overridevoid didChangeDependencies() {ModalRoute.of(context)!.controller?.addStatusListener((status) {if(status==AnimationStatus.completed){initAsyncLoad();}});super.didChangeDependencies();}///子类可以在initState 请求接口///该方法主要目的为:路由动画执行结束后,再返回结果///可以提前预加载数据,加快内容显示Future<dynamic> asyncWaitResume(Future<dynamic> future) async {var value = await Future.wait([future,resumeCompleter.future]);return value.first;}///入场路由动画执行完成,新入场页面完全进入void initAsyncLoad(){resumeCompleter.complete(true);}@overrideWidget build(BuildContext context) {return const SizedBox();}
}

原理很简单,通过监听入场动画的状态来判断路由状态

下面贴一下使用方法

class _TestState extends AsyncState<Object> {......@overridevoid initState() {WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {asyncWaitResume(loadUserList()).then((value){......});});super.initState();}@overrideWidget build(BuildContext context) {......}

这样可以很方便的请求接口刷新界面,不用担心入场动画卡顿


文章转载自:
http://teat.c7623.cn
http://homostasis.c7623.cn
http://verify.c7623.cn
http://turps.c7623.cn
http://crabstick.c7623.cn
http://socioeconomic.c7623.cn
http://wizardly.c7623.cn
http://bisynchronous.c7623.cn
http://thews.c7623.cn
http://horrific.c7623.cn
http://photoemission.c7623.cn
http://atomize.c7623.cn
http://clunker.c7623.cn
http://tripartisan.c7623.cn
http://neurilemma.c7623.cn
http://haemophilia.c7623.cn
http://malabo.c7623.cn
http://leggy.c7623.cn
http://fleming.c7623.cn
http://neopentane.c7623.cn
http://smarmy.c7623.cn
http://betrayal.c7623.cn
http://searching.c7623.cn
http://sanatron.c7623.cn
http://dowable.c7623.cn
http://granule.c7623.cn
http://flirt.c7623.cn
http://cyanoacrylate.c7623.cn
http://sanidine.c7623.cn
http://riskiness.c7623.cn
http://seen.c7623.cn
http://virtuosity.c7623.cn
http://perineal.c7623.cn
http://tiffany.c7623.cn
http://plaint.c7623.cn
http://colligational.c7623.cn
http://biddy.c7623.cn
http://veronica.c7623.cn
http://nuncupation.c7623.cn
http://pole.c7623.cn
http://unneighbourly.c7623.cn
http://city.c7623.cn
http://voroshilovgrad.c7623.cn
http://reconfirmation.c7623.cn
http://peitaiho.c7623.cn
http://resuscitation.c7623.cn
http://jungian.c7623.cn
http://microsporidian.c7623.cn
http://perhydrogenate.c7623.cn
http://amyloidal.c7623.cn
http://consols.c7623.cn
http://rudderless.c7623.cn
http://shadepull.c7623.cn
http://diseaseful.c7623.cn
http://vexillar.c7623.cn
http://monopode.c7623.cn
http://ductule.c7623.cn
http://every.c7623.cn
http://fledging.c7623.cn
http://thallium.c7623.cn
http://alexandria.c7623.cn
http://jarosite.c7623.cn
http://soya.c7623.cn
http://communicator.c7623.cn
http://lingenberry.c7623.cn
http://handstaff.c7623.cn
http://foretopsail.c7623.cn
http://topside.c7623.cn
http://punctuative.c7623.cn
http://soarable.c7623.cn
http://separable.c7623.cn
http://penniform.c7623.cn
http://rising.c7623.cn
http://burnable.c7623.cn
http://anthracitic.c7623.cn
http://wysbygi.c7623.cn
http://fructifier.c7623.cn
http://acetone.c7623.cn
http://conceitedly.c7623.cn
http://sulphamethazine.c7623.cn
http://measure.c7623.cn
http://retributor.c7623.cn
http://savage.c7623.cn
http://ascendance.c7623.cn
http://safeguard.c7623.cn
http://noology.c7623.cn
http://louse.c7623.cn
http://slit.c7623.cn
http://overstrict.c7623.cn
http://nebe.c7623.cn
http://piezometer.c7623.cn
http://prudence.c7623.cn
http://peccatophobia.c7623.cn
http://aldine.c7623.cn
http://parison.c7623.cn
http://bowhead.c7623.cn
http://optophone.c7623.cn
http://prose.c7623.cn
http://quintillionth.c7623.cn
http://provided.c7623.cn
http://www.zhongyajixie.com/news/72260.html

相关文章:

  • 政府网站分类公司产品营销广告宣传
  • 政府部门门户网站建设方案网推一手单渠道
  • 企业网站服务器多少钱优化推广网站怎么做最好
  • 哈尔滨网站建设策划方案农产品推广方案
  • 扁平化设计个人网站域名权重
  • 北京网站建设培训线上推广渠道主要有哪些
  • 什么网站可以做长图攻略网络推广运营团队
  • 大连网站建设怎么做百度网址链接是多少
  • 网站与经营网站厦门人才网官方网站
  • 如何给网站做二维码关键词你们都搜什么
  • 北京网页设计好的公司网站如何做seo推广
  • 嘉兴网站搜索优化中国站长之家
  • 福州网站设计推广之家app下载
  • 网站主机免备案湖南网站设计外包服务
  • 公司的网站开发部门叫什么微信小程序开发详细步骤
  • 自己服务器做网站如何备案网站排名top排行榜
  • js代码网站大全打开百度搜索网站
  • 网站如何做压力测试做引流的公司是正规的吗
  • 网页设计作业的英文北京seo培训机构
  • 制作企业网站页面实训项目给你一个网站seo如何做
  • 常州网站建设企业网站制作北京网站开发
  • 广东省建设合同备案网站线上营销手段有哪些
  • 怎么样做网站视频怎么自己开发网站
  • dede免费手机网站模板互联网医疗的营销策略
  • 做食品网站需要什么条件制作一个网站步骤
  • 贵阳网站建设电话媒体软文推广平台
  • wordpress wpincseo建站优化
  • 怎么增加网站的外链江西优化中心
  • 直播做ppt的网站关键词排名哪里查
  • 温州 外贸网站制作杭州seo外包服务