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

服务网站建设公司广东智能网站建设哪家有

服务网站建设公司,广东智能网站建设哪家有,常州城乡建设学校网站,郑州做网站公flutter开发实战-显示本地图片网络图片及缓存目录图片 在最近开发中碰到了需要显示缓存目录图片#xff0c;这里顺便整理一下#xff0c;显示本地图片、网络图片、缓存目录图片的方法。 一、工程本地图片显示 1 在项目根目录下创建名为 images文件夹#xff0c;也可以将i…flutter开发实战-显示本地图片网络图片及缓存目录图片 在最近开发中碰到了需要显示缓存目录图片这里顺便整理一下显示本地图片、网络图片、缓存目录图片的方法。 一、工程本地图片显示 1 在项目根目录下创建名为 images文件夹也可以将images放在asserts文件夹下2.在pubspec.yaml中配置images相关的路径并执行pub get 使配置的文件生效 在pubspec.yaml文件中 # The following section is specific to Flutter. flutter:# The following line ensures that the Material Icons font is# included with your application, so that you can use the icons in# the material Icons class.uses-material-design: trueassets:- assets/images/- assets/images/common/- assets/images/icons/ 调用本地图片显示代码 Widget _buildLoadingWidget(BuildContext context) {return ImageHelper.wrapAssetAtImages(icons/ic_toast_loading.png,width: 50.0,height: 50.0,);}// ImageHelper.wrapAssetAtImages static Image wrapAssetAtImages(String name,{double? width, double? height, BoxFit? fit}) {return Image.asset(assets/images/ name,width: width,height: height,fit: fit,errorBuilder: (context, url, error) imageErrorHolder(width: width, height: height),);} 还可以使用AssetImage及Image.asset Image(image: AssetImage(assets/images/icons/ic_toast_loading.png),width: 100.0 );Image.asset(assets/images/icons/ic_toast_loading.png,width: 100.0 ); 二、显示网络图片 网络图片显示使用NetworkImage 可以加载网络图片 Image(image: NetworkImage(imageUrl),width: 100.0, ) 使用Image.network Image.network(https://avatars2.githubusercontent.com/u/20411648?s460v4,width: 100.0, ) 使用cached_network_image插件实现加载图片 // 处理网络图片的urlstatic Widget imageNetwork({required String imageUrl,double? width,double? height,BoxFit? fit,Widget? placeholder,Widget? errorHolder}) {double? cacheWidth;if (width ! null) {cacheWidth width * 2.0;}double? cacheHeight;if (height ! null) {cacheHeight height * 2.0;}if (!(imageUrl.isNotEmpty imageUrl.startsWith(http))) {return Container();}String aCropImageUrl ImageHelper.formatImageUrl(imageUrl: imageUrl, width: cacheWidth, height: cacheHeight);return CachedNetworkImage(maxWidthDiskCache: cacheWidth?.round(),maxHeightDiskCache: cacheHeight?.round(),imageUrl: aCropImageUrl,fit: fit,width: width,height: height,placeholder: (context, url) (placeholder ?? Container()),errorWidget: (context, url, error) (errorHolder ?? imageErrorHolder(width: width, height: height)),);}static Widget imageErrorHolder({double? width, double? height}) {return Container(width: width,height: height,);}static Widget placeHolder({double? width, double? height}) {return SizedBox(width: width,height: height,child: CupertinoActivityIndicator(radius: min(10.0, width! / 3)));} 三、加载缓存目录图片 当我们将图片保存到Document、Cache目录下需要将其显示出来知道的ImagePath可以使用File(ImagePath)将图片显示出来。 String? imagePath picArg![imagePath];if (imagePath ! null) {return Image.file(File(imagePath!),width: widget.width,height: widget.height,fit: BoxFit.cover,);} 当然也可以实现ImageProvider来处理显示图片问题 四、小结 flutter开发实战-显示本地图片网络图片及缓存目录图片。显示本地图片、网络图片、缓存目录图片的几种方法 学习记录每天不停进步。
http://www.hkea.cn/news/14556185/

相关文章:

  • 免费网站建设哪个好?辽宁城建设计院有限公司网站
  • 唯品会网站架构购物网站含有哪些模块
  • 上海做营销网站哪个公司好南昌高端网站开发费用表
  • 南昌网站seo哪家公司好腾讯云 门户网站建设
  • 广东白云手机网站建设网站设计与建设报告
  • 怎么在百度创建网站卖网站链接
  • 中细软网站建设同江佳木斯网站制作
  • 宁波网站建设ysdshwordpress api开发文档下载
  • 阳光家园广州网站网址网站项目遇到的问题
  • 坑梓网站建设价格字节跳动小程序官网
  • 免费管理软件开发平台怎么优化网站的单个关键词排名
  • 网站空间商 权限2022年最近一周新闻大事
  • 长沙人才网山西seo
  • 外贸网站商城建设可以自己做漫画的网站
  • 网站建设微信小程序开发o2o信息类平台有哪些
  • 合肥网站制作费用美团网站除佣金表格怎么做
  • 松岗专业做网站公司博客发布 网站模版
  • 网站开发报价表的文档杭州网站建设网络
  • 阿里云1核2g服务器能建设几个网站企点下载官网
  • 做网站价格需要多少钱常德论坛最新消息
  • 网站开发框架排行行业网站推广
  • 西安网站建设专业优化网站排名公司
  • 手机对比网站百度官网
  • 深圳有哪些网站建设公司装饰设计图片
  • 网站开发流程有几个阶段商家怎么入驻微信小程序
  • 彩票网站的统计怎么做杨凌做网站的公司
  • 网站开发时图片加载慢怎么解决网站开发流程荆州
  • 彩票网站建设哪里安卓 wordpress 源码
  • 网站充值记账凭证怎么做wordpress更改主题作者
  • 个人建站网站搬瓦工putty做网站