This commit is contained in:
tao
2025-09-01 09:23:42 +08:00
parent 0af8d30cae
commit 00a81e4e7b
5 changed files with 63 additions and 49 deletions

View File

@@ -3,6 +3,7 @@ import 'dart:io';
import 'package:derma_flutter/router/config/route_paths.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_image_compress/flutter_image_compress.dart';
import 'package:go_router/go_router.dart';
@@ -26,9 +27,13 @@ class _HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin
///打开相机拍照
void _handTakePhoto() async {
var photo = await _picker.pickImage(source: ImageSource.camera);
if (photo != null) {
_startDetect(photo.path);
try {
var photo = await _picker.pickImage(source: ImageSource.camera);
if (photo != null) {
_startDetect(photo.path);
}
} on PlatformException catch (e) {
EasyLoading.showToast(e.message ?? "");
}
}
@@ -46,7 +51,7 @@ class _HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin
///开始检测
void _startDetect(String path) async {
//压缩
final result = await FlutterImageCompress.compressWithFile(
final result = await FlutterImageCompress.compressWithFile(
path,
minWidth: 1080,
minHeight: 1920,