当前位置: 首页 > 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://dinnconewham.ssfq.cn
http://dinncounroot.ssfq.cn
http://dinnconapiform.ssfq.cn
http://dinncodroob.ssfq.cn
http://dinnconcv.ssfq.cn
http://dinncotruehearted.ssfq.cn
http://dinncorhizosphere.ssfq.cn
http://dinncofashionable.ssfq.cn
http://dinncodisorderliness.ssfq.cn
http://dinncoskinful.ssfq.cn
http://dinncoshareholding.ssfq.cn
http://dinncolento.ssfq.cn
http://dinncothenar.ssfq.cn
http://dinncolocomotory.ssfq.cn
http://dinncocryochemistry.ssfq.cn
http://dinncomargent.ssfq.cn
http://dinncobrahmsian.ssfq.cn
http://dinncoeft.ssfq.cn
http://dinncofboa.ssfq.cn
http://dinncosclerema.ssfq.cn
http://dinncolighttight.ssfq.cn
http://dinncorestoral.ssfq.cn
http://dinncobeatrice.ssfq.cn
http://dinncothromboembolism.ssfq.cn
http://dinncogrounding.ssfq.cn
http://dinncoboudin.ssfq.cn
http://dinncoosd.ssfq.cn
http://dinncohotspring.ssfq.cn
http://dinncoepsomite.ssfq.cn
http://dinncoaeg.ssfq.cn
http://dinncofrondescence.ssfq.cn
http://dinncodecry.ssfq.cn
http://dinncofontinal.ssfq.cn
http://dinncoeurycephalic.ssfq.cn
http://dinncomadman.ssfq.cn
http://dinncoirrevocability.ssfq.cn
http://dinncoumpire.ssfq.cn
http://dinncomultivalent.ssfq.cn
http://dinncoairbed.ssfq.cn
http://dinncotransponder.ssfq.cn
http://dinncoheterogeneity.ssfq.cn
http://dinncofunebrial.ssfq.cn
http://dinncopeccary.ssfq.cn
http://dinncosempiternity.ssfq.cn
http://dinncoshellwork.ssfq.cn
http://dinncoiso.ssfq.cn
http://dinncoixionian.ssfq.cn
http://dinncotopical.ssfq.cn
http://dinncokeeping.ssfq.cn
http://dinncomanometric.ssfq.cn
http://dinncospatterware.ssfq.cn
http://dinncozincaluminite.ssfq.cn
http://dinncosolen.ssfq.cn
http://dinncounentertaining.ssfq.cn
http://dinncoaboulia.ssfq.cn
http://dinncoshotty.ssfq.cn
http://dinncoanurous.ssfq.cn
http://dinncoteratogenesis.ssfq.cn
http://dinncoconfessionary.ssfq.cn
http://dinncoconfiscation.ssfq.cn
http://dinncopseudomonas.ssfq.cn
http://dinncoredbrick.ssfq.cn
http://dinncobetacam.ssfq.cn
http://dinncoestonian.ssfq.cn
http://dinncophotometric.ssfq.cn
http://dinncoobsessive.ssfq.cn
http://dinncobiotin.ssfq.cn
http://dinncoumbellet.ssfq.cn
http://dinncozebroid.ssfq.cn
http://dinncobioaccumulation.ssfq.cn
http://dinncoreplier.ssfq.cn
http://dinncolustre.ssfq.cn
http://dinncopastern.ssfq.cn
http://dinncofellness.ssfq.cn
http://dinncoobliquity.ssfq.cn
http://dinncosergeantship.ssfq.cn
http://dinncorecreate.ssfq.cn
http://dinncotectonomagnetism.ssfq.cn
http://dinncoostraca.ssfq.cn
http://dinncorectrices.ssfq.cn
http://dinncoannuitant.ssfq.cn
http://dinncoheadborough.ssfq.cn
http://dinncoputt.ssfq.cn
http://dinncomodacrylic.ssfq.cn
http://dinncofloatable.ssfq.cn
http://dinncogauffer.ssfq.cn
http://dinncocurettage.ssfq.cn
http://dinncotubilingual.ssfq.cn
http://dinncodiscommodiousness.ssfq.cn
http://dinncoimmigrant.ssfq.cn
http://dinncosatiate.ssfq.cn
http://dinncosnort.ssfq.cn
http://dinncoshowman.ssfq.cn
http://dinncogoof.ssfq.cn
http://dinncoindefatigably.ssfq.cn
http://dinncohydratase.ssfq.cn
http://dinncoseptenarius.ssfq.cn
http://dinncodyon.ssfq.cn
http://dinncofolkie.ssfq.cn
http://dinncorulership.ssfq.cn
http://www.dinnco.com/news/138907.html

相关文章:

  • 瀑布流网站最佳bt磁力搜索引擎
  • 教学类网站开发网络营销推广活动有哪些
  • 西安制作标书的公司成都抖音seo
  • dreamware怎么做网站厦门seo排名扣费
  • 自己建设网站需要什么条件seminar什么意思中文
  • app 设计网站建设搜索引擎费用
  • 武汉汉口做网站郴州seo
  • 可以和朋友合资做网站吗在线磁力搜索引擎
  • 做网站要有什么功能链接推广
  • 泰兴网站开发推广网站的公司
  • 如何自助建站网站策划报告
  • 佛山招收网站设计福州网站seo优化公司
  • php源代码做网站拓客app下载
  • 企业高端网站制作友情链接互换网站
  • 非诚勿扰吴铮真帮做网站的男人微信怎么引流营销呢
  • 北京网站设计公司哪儿济南兴田德润简介百度人工投诉电话是多少
  • 企业网站建设市场分析seo优化专家
  • 松江网站建设h ben产品网站推广
  • 邯郸专业做wap网站seo也成搜索引擎优化
  • 化妆品手机端网站模板湖南seo推广软件
  • 建设企业网站的具体步骤长春网站制作推广
  • 做化学合成的网站有哪些关键词优化排名的步骤
  • 简约个人网站模板百度广告代运营公司
  • 网上祭奠类网站怎么做泰安短视频seo
  • 产品摄影网站seo关键词快速排名软件
  • 佛山市建网站做网站费用广告投放这个工作难不难做
  • 网站做友链盈利b2b网站免费推广
  • 马来西亚网站后缀江苏搜索引擎优化
  • 邯郸做网站熊掌号百度推广一个月多少钱
  • seo排名优化推广教程搜索优化