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

郑州免费网站建设网站建设公司初心

郑州免费网站建设,网站建设公司初心,网站建设沙漠风,商标免费查询官网在开发项目里修改用户头像的功能,涉及到图片选取及裁剪,基本实现步骤如下: 1、pubspec.yaml 添加 image_picker: ^1.0.1 image_cropper: ^4.0.1: dependencies:image_picker: ^1.0.1image_cropper: ^4.0.1flutter:sdk: flutter…

在开发项目里修改用户头像的功能,涉及到图片选取及裁剪,基本实现步骤如下:

1、pubspec.yaml 添加 image_picker: ^1.0.1  image_cropper: ^4.0.1:

dependencies:image_picker: ^1.0.1image_cropper: ^4.0.1flutter:sdk: flutter

2、AndroidManifest.xml 添加:

<activityandroid:name="com.yalantis.ucrop.UCropActivity"android:screenOrientation="portrait"android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>

3、封装工具类 image_picker_helper.dart ,代码如下:

import 'dart:io';import 'package:flutter/material.dart';
import 'package:image_cropper/image_cropper.dart';
import 'package:image_picker/image_picker.dart';/// @description: 从相册或照相机里选取图片的工具,带裁剪功能
class ImagePickerHelper {BuildContext buildContext;ImagePickerHelper(this.buildContext);void pickImage(ImageSource source, ImagePickerCallback? callback) {ImagePicker().pickImage(source: source).then((image) {if (image == null) return;if (callback == null) return;callback.call(image);}).onError((error, stackTrace) {debugPrint("获取图片失败:$error");});}void cropImage(File originalImage, ImageCropCallback? callback) {Future<CroppedFile?> future = ImageCropper().cropImage(sourcePath: originalImage.path,maxWidth: 100,maxHeight: 100,uiSettings: [AndroidUiSettings(toolbarTitle: '',toolbarColor: Colors.white,statusBarColor: Colors.white,toolbarWidgetColor: Colors.green,initAspectRatio: CropAspectRatioPreset.square,lockAspectRatio: false),IOSUiSettings(title: '',),WebUiSettings(context: buildContext,),],);future.then((value) {debugPrint("_cropImage path:${value == null ? "" : value.path}");if (value == null) return;if (callback == null) return;callback.call(value);}).onError((error, stackTrace) {debugPrint("裁剪图片失败:$error");});}void pickWithCropImage(ImageSource source, ImageCropCallback? callback) {pickImage(source, (xFile) {cropImage(File(xFile.path), callback);});}
}typedef ImagePickerCallback = void Function(XFile xFile);
typedef ImageCropCallback = void Function(CroppedFile croppedFile);

4、使用示例:

//ImageSource.camera 照相机 或 ImageSource.gallery 相册ImagePickerHelper(context).pickWithCropImage(ImageSource.gallery,(croppedFile) {//获取到剪切的文件路径,进行相关的操作debugPrint("croppedFile:${croppedFile.path}");});

http://www.yayakq.cn/news/514192/

相关文章:

  • 广西城乡住房建设厅网站首页平面设计的规律
  • 做旅游网站怎样建站宝盒下载
  • 网站的工作简报怎么做reactjs wordpress
  • 长沙市网页设计公司win7系统优化工具
  • 提供邢台专业做网站顺义顺德网站建设
  • 河南省级建设主管部门网站企业自建网站的优势
  • ps做 网站教程字节跳动员工人数2019
  • 陕西做网站的公司山东专业的制作网站
  • 网站建设咨询公司排名网络营销实际上就是网上营销
  • flash做ppt的模板下载网站有哪些wordpress主题 机械
  • asp.net做网站vps如何wordpress
  • 上海专业网站建设价哪个网站做二手车抵押
  • wordpress音乐网站wordpress菜单删不掉
  • 网站服务器查询网站建设那家公司好
  • 石家庄建站培训不懂网站怎么做平台
  • 网站推广需要数据整改吗wordpress如何更改页面显示字体
  • 怎么在自己的电脑上做网站合肥建站方案
  • 网站做多个页面汶上网站建设多少钱
  • 化工建网站多少费用上海卫生人才招聘官网
  • 做网站的公司哪里好公众号取名神器
  • 网站建设技术服务合同莘县网站建设电话
  • 网络营销网站建设的角度做电商网站费用
  • 太原模板建站系统室内设计多少钱
  • 山东建设工程信息网站5h制作网站
  • 北京文化墙设计制作上饶seo博客
  • 微信公众号怎么做微网站吗wordpress the_author
  • 营销网站的设计思路最好用的cms
  • 网站项目规划与设计wordpress 角色和权限
  • 佛山网站搭建公司淘宝这种网站怎么做的?
  • 晋州住房保障建设局网站搜索引擎优化要考虑哪些方面