Commit 8c14b97950c7876a4e02577765c12130d7265a73

Authored by wdn127929
1 parent 5eec861b

修复裁剪图点击x后未取消转圈

... ... @@ -219,45 +219,84 @@ class _BookInfoPageState extends State<BookInfoPage> {
Uint8List newImg = await Utils.testFromFileComporessList(
context, afterImg,
needResize: true);
path = await Utils.saveImage(newImg);
}
if (newImg != null) {
path = await Utils.saveImage(newImg);
if (path == null) {
File compressedFile = await FlutterNativeImage.compressImage(
pickedFile.path,
quality: 70,
percentage: 50);
path = compressedFile.path;
}
if (path == null) {
File compressedFile = await FlutterNativeImage.compressImage(
pickedFile.path,
quality: 70,
percentage: 50);
path = compressedFile.path;
}
// File compressedFile = await FlutterNativeImage.compressImage(
// pickedFile.path,
// quality: 50,
// percentage: 50);
setState(() {
if (pickedFile != null) {
imgModel.file = File(pickedFile.path);
imgModel.process = 0.01;
} else {
print('No image selected.');
}
});
if (pickedFile != null) {
// if (title == '头像') {
// _uploadImageProvider.imgSizeTouxiang = 76;
// _uploadImageProvider.touxiang.qiniuUrl = null;
// } else {
// _uploadImageProvider.imgSizeErweima = 76;
// _uploadImageProvider.firstImage.qiniuUrl = null;
imgModel.qiniuUrl = null;
// }
bool need = await Utils.sizeNeed(File(pickedFile.path));
File file = File(pickedFile.path);
if (need) {
file = File(path);
}
UploadImageUtil()
.startUploadOnly(context, file, type, true, _uploadImageProvider);
}
}
} else {
if (path == null) {
File compressedFile = await FlutterNativeImage.compressImage(
pickedFile.path,
quality: 70,
percentage: 50);
path = compressedFile.path;
}
// File compressedFile = await FlutterNativeImage.compressImage(
// pickedFile.path,
// quality: 50,
// percentage: 50);
setState(() {
// File compressedFile = await FlutterNativeImage.compressImage(
// pickedFile.path,
// quality: 50,
// percentage: 50);
setState(() {
if (pickedFile != null) {
imgModel.file = File(pickedFile.path);
imgModel.process = 0.01;
} else {
print('No image selected.');
}
});
if (pickedFile != null) {
imgModel.file = File(pickedFile.path);
imgModel.process = 0.01;
} else {
print('No image selected.');
}
});
if (pickedFile != null) {
// if (title == '头像') {
// _uploadImageProvider.imgSizeTouxiang = 76;
// _uploadImageProvider.touxiang.qiniuUrl = null;
// } else {
// _uploadImageProvider.imgSizeErweima = 76;
// _uploadImageProvider.firstImage.qiniuUrl = null;
imgModel.qiniuUrl = null;
// }
bool need = await Utils.sizeNeed(File(pickedFile.path));
File file = File(pickedFile.path);
if (need) {
file = File(path);
// if (title == '头像') {
// _uploadImageProvider.imgSizeTouxiang = 76;
// _uploadImageProvider.touxiang.qiniuUrl = null;
// } else {
// _uploadImageProvider.imgSizeErweima = 76;
// _uploadImageProvider.firstImage.qiniuUrl = null;
imgModel.qiniuUrl = null;
// }
bool need = await Utils.sizeNeed(File(pickedFile.path));
File file = File(pickedFile.path);
if (need) {
file = File(path);
}
UploadImageUtil()
.startUploadOnly(context, file, type, true, _uploadImageProvider);
}
UploadImageUtil()
.startUploadOnly(context, file, type, true, _uploadImageProvider);
}
}
... ... @@ -794,7 +833,7 @@ class _BookInfoPageState extends State<BookInfoPage> {
if (qiniuUrl != null && qiniuUrl != '') {
// _uploadImageProvider.logo.process = 0;
// setState(() {
// });
// setState(() {});
// tempList.add(qiniuUrl);
... ...
... ... @@ -635,29 +635,31 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> {
Uint8List afterImg = await yourFile.readAsBytes();
Uint8List newImg = await Utils.testFromFileComporessList(context, afterImg,
needResize: true);
String path = await Utils.saveImage(newImg);
if (path == null) {
File compressedFile = await FlutterNativeImage.compressImage(
pickedFile.path,
quality: 70,
percentage: 50);
path = compressedFile.path;
}
//更新本地存储,上传中展示
setState(() {
if (newImg != null) {
String path = await Utils.saveImage(newImg);
if (path == null) {
File compressedFile = await FlutterNativeImage.compressImage(
pickedFile.path,
quality: 70,
percentage: 50);
path = compressedFile.path;
}
//更新本地存储,上传中展示
setState(() {
if (pickedFile != null) {
imgModel.file = File(path);
imgModel.process = 0.01;
} else {
print('No image selected.');
}
});
if (pickedFile != null) {
imgModel.file = File(path);
imgModel.process = 0.01;
} else {
print('No image selected.');
_uploadImageProvider.mentou.qiniuUrl = null;
_uploadImageProvider.mentou.file = File(path);
_uploadImageProvider.mentou.path = path;
UploadImageUtil().startUploadOnly(
context, File(path), 2, true, _uploadImageProvider);
}
});
if (pickedFile != null) {
_uploadImageProvider.mentou.qiniuUrl = null;
_uploadImageProvider.mentou.file = File(path);
_uploadImageProvider.mentou.path = path;
UploadImageUtil()
.startUploadOnly(context, File(path), 2, true, _uploadImageProvider);
}
}
... ...
... ... @@ -1584,6 +1584,11 @@ class Utils {
Uint8List result = list;
if (needResize) {
result = await resizeImage(list); //重置图片尺寸
if (result == null) {
//取消重置尺寸
Loading.hideLoading(context);
return null;
}
}
Uint8List resultnew = await realComporessList(result); //压缩图片
... ... @@ -1603,6 +1608,11 @@ class Utils {
Loading.showLoading(context);
Uint8List list = await downloadFile(url); //下载图片
Uint8List result = await resizeImage(list); //重置图片尺寸
if (result == null) {
//取消重置尺寸
Loading.hideLoading(context);
return null;
}
Uint8List resultnew = await realComporessList(result); //压缩图片
Loading.hideLoading(context);
... ... @@ -1685,8 +1695,8 @@ class Utils {
*/
//image_cropper插件,中心点裁剪固定比例的图片
String imgPath = await saveImage(data);
Uint8List afterImg = data;
// Uint8List afterImg = data;
Uint8List afterImg;
if (imgPath != null) {
final croppedImage = await ImageCropper().cropImage(
sourcePath: imgPath,
... ... @@ -1719,9 +1729,11 @@ class Utils {
],
);
print(croppedImage);
File yourFile = File(croppedImage.path);
if (croppedImage != null) {
File yourFile = File(croppedImage.path);
afterImg = await yourFile.readAsBytes();
afterImg = await yourFile.readAsBytes();
}
}
// IMG.Image decodedImage = IMG.decodeImage(data);
... ...