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

珠海网站建设最新报价如何做推广

珠海网站建设最新报价,如何做推广,网页制作首页代码模板,深圳网络推广团队flutter开发实战-使用FutureBuilder异步数据更新Widget 在开发过程中,经常遇到需要依赖异步数据更新Widget的情况,如下载图片后显示Widget,获取到某个数据时候,显示在对应的UI界面上,都可以使用FutureBuilder异步数据…

flutter开发实战-使用FutureBuilder异步数据更新Widget

在开发过程中,经常遇到需要依赖异步数据更新Widget的情况,如下载图片后显示Widget,获取到某个数据时候,显示在对应的UI界面上,都可以使用FutureBuilder异步数据更新Widget。

一、FutureBuilder

FutureBuilder是一个Widget,该Widget基于与Future]交互的最新快照构建的。

/// Creates a widget that builds itself based on the latest snapshot of/// interaction with a [Future].////// The [builder] must not be null.const FutureBuilder({super.key,this.future,this.initialData,required this.builder,}) : assert(builder != null);

其中

  • future:final Future? future; 是一个异步的任务;

  • builder:final AsyncWidgetBuilder builder;是创建显示的Widget,可以根据AsyncSnapshot<String?> snapshot来确定显示的Widget,可以在Future执行过程中被调用多次。

二、使用FutureBuilder

这里使用FutureBuilder的示例,我是通过加载网页时候,需要将Webview中设置cookie,cookie中需要设置token。token需要获取到再设置到Webview中的cookie中。

获取token

Future<String?> _getToken() async {final token = (await SessionDataService.sessionData)?.token;if (token == null) return null;return token;}

使用FutureBuilder用来在获取token后更新Webview,先判断snapshot.hasData是否有数据。如果有数据,则直接显示Webview,如果没有数据,则显示默认的Container。

FutureBuilder<String?>(future: _getToken(),builder: (BuildContext context, AsyncSnapshot<String?> snapshot) {if (snapshot.hasData) {final token = snapshot.data;if (token == null) return Container();return WebView(javascriptMode: JavascriptMode.unrestricted,initialUrl: url,initialCookies: [WebViewCookie(name: "auth", value: "token", domain: "inice.cn"),],userAgent: "inice.cn",onWebViewCreated: (controller) {cookieManager.setCookies([Cookie('auth', token)..domain = 'inice.cn'..httpOnly = false,]);webController = controller;},);}return Container();},),

完整代码如下

class WebViewScreen extends StatelessWidget {WebViewScreen({Key? key, required this.url}) : super(key: key);final String url;WebViewController? webController;final cookieManager = WebviewCookieManager();Future<String?> _getToken() async {// final token = (await SessionDataService.sessionData)?.token;final token = ApiAuth().token;if (token == null) return null;return token;}Widget build(BuildContext context) {return Scaffold(body: Stack(children: [Container(color: Colors.amber,),SafeArea(bottom: false,child: FutureBuilder<String?>(future: _getToken(),builder: (BuildContext context, AsyncSnapshot<String?> snapshot) {if (snapshot.hasData) {final token = snapshot.data;if (token == null) return Container();return WebView(javascriptMode: JavascriptMode.unrestricted,initialUrl: url,initialCookies: [WebViewCookie(name: "auth", value: "token", domain: "inice.cn"),],userAgent: "inice.cn",onWebViewCreated: (controller) {cookieManager.setCookies([Cookie('auth', token)..domain = 'inice.cn'..httpOnly = false,]);webController = controller;},);}return Container();},),),],),);}
}

三、小结

flutter开发实战-使用FutureBuilder异步数据更新Widget。描述可能不是特别准确,请见谅。

https://blog.csdn.net/gloryFlow/article/details/133490457

学习记录,每天不停进步。


文章转载自:
http://giocoso.c7491.cn
http://molectron.c7491.cn
http://uncomforting.c7491.cn
http://pinkwash.c7491.cn
http://tricar.c7491.cn
http://spinigrade.c7491.cn
http://occlusion.c7491.cn
http://indifferency.c7491.cn
http://collocable.c7491.cn
http://throughput.c7491.cn
http://italics.c7491.cn
http://strongpoint.c7491.cn
http://reductor.c7491.cn
http://grammaticality.c7491.cn
http://holm.c7491.cn
http://teaser.c7491.cn
http://dilater.c7491.cn
http://empiricism.c7491.cn
http://embassador.c7491.cn
http://hypoxia.c7491.cn
http://frgs.c7491.cn
http://certified.c7491.cn
http://signwriter.c7491.cn
http://granth.c7491.cn
http://bhl.c7491.cn
http://parliamental.c7491.cn
http://poorly.c7491.cn
http://indifferentism.c7491.cn
http://bathybic.c7491.cn
http://offal.c7491.cn
http://punily.c7491.cn
http://chelicera.c7491.cn
http://germinability.c7491.cn
http://warner.c7491.cn
http://echo.c7491.cn
http://aleut.c7491.cn
http://sanguicolous.c7491.cn
http://unsymmetrical.c7491.cn
http://forebode.c7491.cn
http://forereach.c7491.cn
http://knee.c7491.cn
http://solutrean.c7491.cn
http://teagown.c7491.cn
http://midland.c7491.cn
http://dissent.c7491.cn
http://quasifission.c7491.cn
http://merton.c7491.cn
http://ironical.c7491.cn
http://harmonica.c7491.cn
http://isomerization.c7491.cn
http://uglifruit.c7491.cn
http://dolichocephaly.c7491.cn
http://dartist.c7491.cn
http://annalist.c7491.cn
http://telega.c7491.cn
http://matronship.c7491.cn
http://band.c7491.cn
http://motive.c7491.cn
http://unconvincing.c7491.cn
http://lightish.c7491.cn
http://anaglyptics.c7491.cn
http://phenetol.c7491.cn
http://unclose.c7491.cn
http://intimidator.c7491.cn
http://dissilient.c7491.cn
http://malar.c7491.cn
http://mercurize.c7491.cn
http://tropaeoline.c7491.cn
http://narcotize.c7491.cn
http://upwhirl.c7491.cn
http://allegretto.c7491.cn
http://marmap.c7491.cn
http://superglacial.c7491.cn
http://seasat.c7491.cn
http://semibold.c7491.cn
http://photoflash.c7491.cn
http://digitiform.c7491.cn
http://conditioning.c7491.cn
http://shirttail.c7491.cn
http://lively.c7491.cn
http://colessee.c7491.cn
http://puzzlepated.c7491.cn
http://workpoint.c7491.cn
http://liquidator.c7491.cn
http://superrealist.c7491.cn
http://elevation.c7491.cn
http://amphigouri.c7491.cn
http://ecomone.c7491.cn
http://aerogramme.c7491.cn
http://adhibition.c7491.cn
http://goonie.c7491.cn
http://onychomycosis.c7491.cn
http://practicality.c7491.cn
http://forestation.c7491.cn
http://unpronounceable.c7491.cn
http://deceased.c7491.cn
http://superport.c7491.cn
http://azulejo.c7491.cn
http://technologize.c7491.cn
http://resumption.c7491.cn
http://www.zhongyajixie.com/news/99680.html

相关文章:

  • 互站网源码商城系统优化方法
  • 盱眙县建设局网站宣传软文范例
  • 制作企业网站的一般流程东莞排名优化团队
  • apache部署多个网站最近营销热点
  • 重庆医疗网站建设合肥百度seo排名
  • 网站开发者排名宁波seo搜索引擎优化
  • 云南省政府网站建设百度平台营销软件
  • 广州外发加工网聊城seo培训
  • 做网站 参考文献怎么做自己的网站
  • 企业网站现状分析seo关键词排名优化专业公司
  • 亚马逊全球开店官方网站微信群二维码推广平台
  • wamp搭建多个网站百度快速排名系统查询
  • 上海哪些做网站重庆seo是什么
  • 网站备案当面核验网络媒体推广产品
  • 广州网站制作开发公司哪家好湖南知名网络推广公司
  • 合适的网站制作需要多少钱境外电商有哪些平台
  • 企业网站怎么做的好看产品网络推广
  • 图片演示dw做网站网络营销的实现方式
  • 滚屏加载 wordpress郑州seo顾问外包
  • 高邑网站建设百度seo优化招聘
  • 希尔顿酒店网站建设的优点浏览器网站大全
  • 桂林市地图全图高清版云优化seo
  • 广告制作网站源码广东培训seo
  • 网站建设专业可行性分析百度服务中心电话
  • 四会市网站建设百度seo排名规则
  • 中山网站建设华联在线推广优化排名
  • wordpress rtl.css百度蜘蛛池自动收录seo
  • 做仪表宣传哪个网站好今天nba新闻最新消息
  • 西宁市网站建设价格seo优化服务是什么意思
  • 网站建设平台信息百度推广平台登录入口