Merge remote-tracking branch 'origin/main'
# Conflicts: # .flutter-plugins-dependencies # .idea/libraries/Dart_Packages.xml # .idea/libraries/Flutter_Plugins.xml # example/pubspec.lock # pubspec.lock
This commit is contained in:
@@ -241,6 +241,42 @@
|
|||||||
"packageUri": "lib/",
|
"packageUri": "lib/",
|
||||||
"languageVersion": "2.12"
|
"languageVersion": "2.12"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "flutter_image_compress",
|
||||||
|
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/flutter_image_compress-2.4.0",
|
||||||
|
"packageUri": "lib/",
|
||||||
|
"languageVersion": "2.12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "flutter_image_compress_common",
|
||||||
|
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/flutter_image_compress_common-1.0.6",
|
||||||
|
"packageUri": "lib/",
|
||||||
|
"languageVersion": "2.12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "flutter_image_compress_macos",
|
||||||
|
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/flutter_image_compress_macos-1.0.3",
|
||||||
|
"packageUri": "lib/",
|
||||||
|
"languageVersion": "2.12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "flutter_image_compress_ohos",
|
||||||
|
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/flutter_image_compress_ohos-0.0.3",
|
||||||
|
"packageUri": "lib/",
|
||||||
|
"languageVersion": "2.12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "flutter_image_compress_platform_interface",
|
||||||
|
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/flutter_image_compress_platform_interface-1.0.5",
|
||||||
|
"packageUri": "lib/",
|
||||||
|
"languageVersion": "2.12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "flutter_image_compress_web",
|
||||||
|
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/flutter_image_compress_web-0.1.5",
|
||||||
|
"packageUri": "lib/",
|
||||||
|
"languageVersion": "2.12"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "flutter_inappwebview",
|
"name": "flutter_inappwebview",
|
||||||
"rootUri": "file:///Users/threeone/.pub-cache/hosted/pub.flutter-io.cn/flutter_inappwebview-6.1.5",
|
"rootUri": "file:///Users/threeone/.pub-cache/hosted/pub.flutter-io.cn/flutter_inappwebview-6.1.5",
|
||||||
@@ -649,6 +685,18 @@
|
|||||||
"packageUri": "lib/",
|
"packageUri": "lib/",
|
||||||
"languageVersion": "3.8"
|
"languageVersion": "3.8"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "photo_manager",
|
||||||
|
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/photo_manager-3.8.3",
|
||||||
|
"packageUri": "lib/",
|
||||||
|
"languageVersion": "2.13"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "photo_manager_image_provider",
|
||||||
|
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/photo_manager_image_provider-2.2.0",
|
||||||
|
"packageUri": "lib/",
|
||||||
|
"languageVersion": "2.13"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "photo_view",
|
"name": "photo_view",
|
||||||
"rootUri": "file:///Users/threeone/.pub-cache/hosted/pub.flutter-io.cn/photo_view-0.15.0",
|
"rootUri": "file:///Users/threeone/.pub-cache/hosted/pub.flutter-io.cn/photo_view-0.15.0",
|
||||||
@@ -1015,6 +1063,18 @@
|
|||||||
"packageUri": "lib/",
|
"packageUri": "lib/",
|
||||||
"languageVersion": "3.4"
|
"languageVersion": "3.4"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "wechat_assets_picker",
|
||||||
|
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/wechat_assets_picker-10.1.0",
|
||||||
|
"packageUri": "lib/",
|
||||||
|
"languageVersion": "3.6"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "wechat_picker_library",
|
||||||
|
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/wechat_picker_library-1.0.7",
|
||||||
|
"packageUri": "lib/",
|
||||||
|
"languageVersion": "3.4"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "win32",
|
"name": "win32",
|
||||||
"rootUri": "file:///Users/threeone/.pub-cache/hosted/pub.flutter-io.cn/win32-5.15.0",
|
"rootUri": "file:///Users/threeone/.pub-cache/hosted/pub.flutter-io.cn/win32-5.15.0",
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ class HttpUtils {
|
|||||||
BaseOptions options = BaseOptions(
|
BaseOptions options = BaseOptions(
|
||||||
baseUrl: baseUrl,
|
baseUrl: baseUrl,
|
||||||
contentType: 'application/json; charset=utf-8',
|
contentType: 'application/json; charset=utf-8',
|
||||||
connectTimeout: const Duration(milliseconds: 15000),
|
connectTimeout: const Duration(seconds: 60),
|
||||||
receiveTimeout: const Duration(milliseconds: 15000),
|
receiveTimeout: const Duration(seconds: 60),
|
||||||
responseType: ResponseType.json,
|
responseType: ResponseType.json,
|
||||||
validateStatus: (status) {
|
validateStatus: (status) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -77,6 +77,10 @@ class UploadOss {
|
|||||||
);
|
);
|
||||||
print("response ===== $response");
|
print("response ===== $response");
|
||||||
EasyLoading.dismiss();
|
EasyLoading.dismiss();
|
||||||
|
if(fileType == 'jpg'){
|
||||||
|
/// 删除临时文件
|
||||||
|
File(path).deleteSync();
|
||||||
|
}
|
||||||
// 成功后返回文件访问路径
|
// 成功后返回文件访问路径
|
||||||
return "$ossHost/$ossDirectory$pathName";
|
return "$ossHost/$ossDirectory$pathName";
|
||||||
} on DioError catch (e) {
|
} on DioError catch (e) {
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ class _UploadImagesState extends State<UploadImages> {
|
|||||||
title: const Text('上传图片'),
|
title: const Text('上传图片'),
|
||||||
message: (max == null || max == 0)
|
message: (max == null || max == 0)
|
||||||
? null
|
? null
|
||||||
: Text('请选择上传方式\n相册最多${max ?? 9}张'),
|
: Text('请选择上传方式\n相册最多$max张'),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
CupertinoActionSheetAction(
|
CupertinoActionSheetAction(
|
||||||
child: const Text('拍照上传'),
|
child: const Text('拍照上传'),
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter_common/upload_image/ossUtil.dart';
|
import 'package:flutter_common/upload_image/ossUtil.dart';
|
||||||
|
import 'package:flutter_image_compress/flutter_image_compress.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
|
||||||
// import 'package:images_picker/images_picker.dart';
|
// import 'package:images_picker/images_picker.dart';
|
||||||
// import 'package:images_picker/images_picker.dart';
|
// import 'package:images_picker/images_picker.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
|
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
|
||||||
|
|
||||||
class UploadImagesTool {
|
class UploadImagesTool {
|
||||||
static uploadImagesTool({
|
static uploadImagesTool({
|
||||||
@@ -136,9 +139,7 @@ class UploadImagesTool {
|
|||||||
)
|
)
|
||||||
: CupertinoActionSheet(
|
: CupertinoActionSheet(
|
||||||
title: const Text('上传图片'),
|
title: const Text('上传图片'),
|
||||||
message: (max == null || max == 0)
|
message: (max == null || max == 0) ? null : Text('请选择上传方式\n相册最多${max}张'),
|
||||||
? null
|
|
||||||
: Text('请选择上传方式\n相册最多${max ?? 9}张'),
|
|
||||||
actions: isAddOtherWidget != null
|
actions: isAddOtherWidget != null
|
||||||
? <Widget>[
|
? <Widget>[
|
||||||
isAddOtherWidget,
|
isAddOtherWidget,
|
||||||
@@ -152,8 +153,7 @@ class UploadImagesTool {
|
|||||||
policy: policy ?? '',
|
policy: policy ?? '',
|
||||||
callback: callback ?? '',
|
callback: callback ?? '',
|
||||||
signature: signature ?? '',
|
signature: signature ?? '',
|
||||||
chooseImages: (list) =>
|
chooseImages: (list) => chooseImages?.call(list),
|
||||||
chooseImages?.call(list),
|
|
||||||
);
|
);
|
||||||
Get.back();
|
Get.back();
|
||||||
},
|
},
|
||||||
@@ -169,8 +169,7 @@ class UploadImagesTool {
|
|||||||
policy: policy ?? '',
|
policy: policy ?? '',
|
||||||
callback: callback ?? '',
|
callback: callback ?? '',
|
||||||
signature: signature ?? '',
|
signature: signature ?? '',
|
||||||
chooseImages: (list) =>
|
chooseImages: (list) => chooseImages?.call(list),
|
||||||
chooseImages?.call(list),
|
|
||||||
);
|
);
|
||||||
Get.back();
|
Get.back();
|
||||||
},
|
},
|
||||||
@@ -187,8 +186,7 @@ class UploadImagesTool {
|
|||||||
policy: policy ?? '',
|
policy: policy ?? '',
|
||||||
callback: callback ?? '',
|
callback: callback ?? '',
|
||||||
signature: signature ?? '',
|
signature: signature ?? '',
|
||||||
chooseImages: (list) =>
|
chooseImages: (list) => chooseImages?.call(list),
|
||||||
chooseImages?.call(list),
|
|
||||||
);
|
);
|
||||||
Get.back();
|
Get.back();
|
||||||
},
|
},
|
||||||
@@ -205,8 +203,7 @@ class UploadImagesTool {
|
|||||||
callback: callback ?? '',
|
callback: callback ?? '',
|
||||||
signature: signature ?? '',
|
signature: signature ?? '',
|
||||||
isShowLoading: isShowLoading,
|
isShowLoading: isShowLoading,
|
||||||
chooseImages: (list) =>
|
chooseImages: (list) => chooseImages?.call(list),
|
||||||
chooseImages?.call(list),
|
|
||||||
);
|
);
|
||||||
Get.back();
|
Get.back();
|
||||||
},
|
},
|
||||||
@@ -235,6 +232,9 @@ class UploadImagesTool {
|
|||||||
}) async {
|
}) async {
|
||||||
XFile? file = await ImagePicker().pickImage(
|
XFile? file = await ImagePicker().pickImage(
|
||||||
source: ImageSource.camera,
|
source: ImageSource.camera,
|
||||||
|
maxHeight: 1080,
|
||||||
|
maxWidth: 1920,
|
||||||
|
imageQuality: 80
|
||||||
);
|
);
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
Get.back();
|
Get.back();
|
||||||
@@ -265,7 +265,11 @@ class UploadImagesTool {
|
|||||||
bool? isShowLoading,
|
bool? isShowLoading,
|
||||||
}) async {
|
}) async {
|
||||||
if (isVideo == true) {
|
if (isVideo == true) {
|
||||||
XFile? video = await ImagePicker().pickVideo(source: ImageSource.gallery);
|
final List<AssetEntity>? result = await AssetPicker.pickAssets(
|
||||||
|
Get.context!,
|
||||||
|
pickerConfig: AssetPickerConfig(maxAssets: 1, requestType: RequestType.video),
|
||||||
|
);
|
||||||
|
final File? video = await result?.first.file;
|
||||||
String path = await saveNetworkImgGallery(
|
String path = await saveNetworkImgGallery(
|
||||||
video?.path ?? '',
|
video?.path ?? '',
|
||||||
fileType: 'mp4',
|
fileType: 'mp4',
|
||||||
@@ -277,11 +281,34 @@ class UploadImagesTool {
|
|||||||
signature: signature ?? '',
|
signature: signature ?? '',
|
||||||
);
|
);
|
||||||
chooseImages?.call([path]);
|
chooseImages?.call([path]);
|
||||||
print('video path ============ $path');
|
|
||||||
} else {
|
} else {
|
||||||
List<XFile>? images = await ImagePicker().pickMultiImage();
|
/// 创建临时目录
|
||||||
|
final Directory tempDir = Directory.systemTemp.createTempSync('compressed_images_');
|
||||||
|
final List<AssetEntity>? result = await AssetPicker.pickAssets(
|
||||||
|
Get.context!,
|
||||||
|
pickerConfig: AssetPickerConfig(maxAssets: max ?? 50),
|
||||||
|
);
|
||||||
|
/// 临时存储选中的图片
|
||||||
|
final List<XFile> selectedFiles = [];
|
||||||
|
if (result != null && result.isNotEmpty) {
|
||||||
|
for (int i = 0; i < result.length; i++) {
|
||||||
|
final File? file = await result[i].file;
|
||||||
|
if (file != null) {
|
||||||
|
/// 获取文件扩展名
|
||||||
|
final String extension = file.absolute.path.split('.').last;
|
||||||
|
/// 压缩并保存到临时文件
|
||||||
|
final XFile? compressedFile = await FlutterImageCompress.compressAndGetFile(
|
||||||
|
file.absolute.path, '${tempDir.path}/${DateTime.now().millisecondsSinceEpoch}_compressed.$extension',
|
||||||
|
quality: 80, minWidth: 1920, minHeight: 1080);
|
||||||
|
if (compressedFile != null) {
|
||||||
|
selectedFiles.add(compressedFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// 上传选中的图片
|
||||||
List<String> list = [];
|
List<String> list = [];
|
||||||
for (var element in images) {
|
for (var element in selectedFiles) {
|
||||||
String path = await saveNetworkImgGallery(
|
String path = await saveNetworkImgGallery(
|
||||||
element.path,
|
element.path,
|
||||||
oSSAccessKeyId: oSSAccessKeyId ?? '',
|
oSSAccessKeyId: oSSAccessKeyId ?? '',
|
||||||
@@ -333,7 +360,7 @@ class UploadImagesTool {
|
|||||||
String? signature,
|
String? signature,
|
||||||
String? ossDirectory,
|
String? ossDirectory,
|
||||||
String? ossHost,
|
String? ossHost,
|
||||||
bool? isShowLoading,
|
bool? isShowLoading,
|
||||||
}) async {
|
}) async {
|
||||||
String string = await UploadOss.upload(
|
String string = await UploadOss.upload(
|
||||||
path,
|
path,
|
||||||
|
|||||||
@@ -96,16 +96,29 @@ class CustomerImagesNetworking extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
String? sizeParams = '';
|
||||||
|
int tempHeight = 300;
|
||||||
|
int tempWidth = 300;
|
||||||
|
if (height != null) {
|
||||||
|
sizeParams = '?x-oss-process=image/resize,h_$tempHeight,w_$tempHeight';
|
||||||
|
}
|
||||||
|
if (width != null) {
|
||||||
|
tempWidth = width!.toInt() <= 300 ? 300 : width!.toInt();
|
||||||
|
sizeParams = '?x-oss-process=image/resize,h_$tempWidth,w_$tempWidth';
|
||||||
|
}
|
||||||
|
if (height != null && width != null) {
|
||||||
|
tempHeight = height!.toInt() <= 300 ? 300 : height!.toInt();
|
||||||
|
sizeParams = '?x-oss-process=image/resize,h_$tempHeight,w_$tempWidth';
|
||||||
|
}
|
||||||
return CachedNetworkImage(
|
return CachedNetworkImage(
|
||||||
imageUrl: imageUrl,
|
imageUrl: imageUrl + sizeParams,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
fit: fit,
|
fit: fit,
|
||||||
errorWidget: (_, object, s) {
|
errorWidget: (_, object, s) {
|
||||||
return Container(
|
return SizedBox(
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
padding: EdgeInsets.all((width ?? 0) / 2),
|
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
'assets/images/noContainer.png',
|
'assets/images/noContainer.png',
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ dependencies:
|
|||||||
image_editor_plus: ^1.0.6
|
image_editor_plus: ^1.0.6
|
||||||
path_provider: ^2.1.5
|
path_provider: ^2.1.5
|
||||||
cached_network_image: ^3.4.1
|
cached_network_image: ^3.4.1
|
||||||
|
wechat_assets_picker: ^10.1.0
|
||||||
|
flutter_image_compress: ^2.4.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user