压缩图片
This commit is contained in:
@@ -9,9 +9,13 @@ import 'package:dio/dio.dart';
|
||||
import '../dto/article_dto.dart';
|
||||
|
||||
///皮肤检测
|
||||
Future<SkinCheckDto> skinDetectApi(String path) async {
|
||||
Future<SkinCheckDto> skinDetectApi(List<int> bytes) async {
|
||||
FormData formData = FormData.fromMap({
|
||||
"skin_image": await MultipartFile.fromFile(path),
|
||||
"skin_image": MultipartFile.fromBytes(
|
||||
bytes,
|
||||
filename: "upload.jpg",
|
||||
contentType: DioMediaType("image", "jpeg"),
|
||||
),
|
||||
});
|
||||
var res = await Request().post("/skin/check", formData);
|
||||
return SkinCheckDto.fromJson(res);
|
||||
@@ -40,15 +44,15 @@ Future<RecordListDto> skinRecordApi({
|
||||
}
|
||||
|
||||
///获取文章列表
|
||||
Future<List<ArticleDto>> articleListApi() async{
|
||||
var res = await Request().get("/customer-health/get_articles");
|
||||
return (res['list'] as List).map((e) => ArticleDto.fromJson(e)).toList();
|
||||
Future<List<ArticleDto>> articleListApi() async {
|
||||
var res = await Request().get("/customer-health/get_articles");
|
||||
return (res['list'] as List).map((e) => ArticleDto.fromJson(e)).toList();
|
||||
}
|
||||
|
||||
///文章详情
|
||||
Future<ArticleDetailDto> articleDetailApi(String id) async{
|
||||
var res = await Request().get("/customer-health/get_article_detail", {
|
||||
"id": id,
|
||||
});
|
||||
return ArticleDetailDto.fromJson(res);
|
||||
}
|
||||
Future<ArticleDetailDto> articleDetailApi(String id) async {
|
||||
var res = await Request().get("/customer-health/get_article_detail", {
|
||||
"id": id,
|
||||
});
|
||||
return ArticleDetailDto.fromJson(res);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
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_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_image_compress/flutter_image_compress.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
@@ -42,11 +45,21 @@ class _HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin
|
||||
|
||||
///开始检测
|
||||
void _startDetect(String path) async {
|
||||
//压缩
|
||||
final result = await FlutterImageCompress.compressWithFile(
|
||||
path,
|
||||
minWidth: 1080,
|
||||
minHeight: 1920,
|
||||
quality: 85,
|
||||
rotate: 0,
|
||||
);
|
||||
print("压缩前:${File(path).lengthSync()}");
|
||||
print("压缩后长度${result?.length}");
|
||||
EasyLoading.show(
|
||||
status: 'Skin analysis in progress, please wait...',
|
||||
maskType: EasyLoadingMaskType.clear,
|
||||
);
|
||||
var res = await skinDetectApi(path);
|
||||
var res = await skinDetectApi(result!);
|
||||
EasyLoading.dismiss();
|
||||
context.push(RoutePaths.detail, extra: res);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user