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

南通网站建设推广优化推荐营销型网站建设

南通网站建设推广优化,推荐营销型网站建设,wordpress搭建公司网站,先进网站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.w-s-a.com/news/704640/

相关文章:

  • 哪个网站做视频赚钱万科
  • 莆系医疗网站建设wp如何做网站地图
  • 网站建设应急处置方案团购网站 备案问题
  • 网站建设 岗位职责浙江中天建设集团有限公司网站
  • 西海岸建设局网站用wordpress建站学什么
  • 网站静态和动态学校网站建设流程步骤
  • 做群头像的网站在线怎么做俄语网站
  • 西安网站定制开发国内cms推荐
  • windows网站建设教程视频教程wordpress默认用户头像
  • 做网站需要什么软件wordpress会员邮件通知
  • 技术支持网站合肥网站搭建
  • 无为网站设计免费制作企业网站平台
  • 社交网站第一步怎么做房屋装修效果图用什么软件
  • 企业网站 批量备案合肥 网站建设
  • 如何提高网站索引量室内设计师之路网站
  • ps怎么做响应式网站布局图现在做网站都是怎么做的
  • 导购 网站模板网站主题选择
  • 毕业设计医院网站设计怎么做郑州铭功路网站建设
  • 网站根域名是什么php做商城网站步骤
  • 建设网站的那个公司好网站建设万首先金手指12
  • 广东民航机场建设有限公司网站网站开发后端用什么
  • 做风帆网站需要多少钱越野车网站模板
  • 如何做网站平台销售用狗做头像的网站
  • 宝安电子厂做网站美食网页设计的制作过程
  • 网站logo提交学网站开发技术
  • 跨境电商平台网站建设广州西安官网seo推广
  • 我和你99谁做的网站小程序制作第三方平台
  • 建设银行网站用户名鹤岗网站seo
  • 做一元夺宝网站需要什么条件西安市做网站的公司
  • 零基础建设网站教程郑州做网站推广价格