feature(image): Добавлен редактор фото

This commit is contained in:
2025-09-08 21:47:51 +03:00
parent 6cb9e82e61
commit 90531e6e4e
14 changed files with 133 additions and 25 deletions

View File

@@ -3,6 +3,7 @@ import 'package:auto_route/auto_route.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:image_cropper/image_cropper.dart';
import 'package:path_provider/path_provider.dart';
import 'package:remever/common/functions.dart';
import 'package:remever/common/resources.dart';
@@ -65,15 +66,33 @@ class _CreateScreenState extends State<CreateScreen> {
}
final String fileName = path.basename(filePath);
final String destinationPath = path.join(ticketsDirPath, fileName);
final copiedFile = await File(filePath).copy(destinationPath);
final String destinationPath = path.join(
ticketsDirPath,
'${DateTime.now()}$fileName',
);
final croppedFile = await ImageCropper().cropImage(
sourcePath: filePath,
aspectRatio: const CropAspectRatio(ratioX: 1, ratioY: 1),
uiSettings: [
AndroidUiSettings(
toolbarTitle: '',
initAspectRatio: CropAspectRatioPreset.square,
lockAspectRatio: true,
),
],
);
if (croppedFile == null) return;
await File(croppedFile.path).copy(destinationPath);
safeSetState(() {
_dto =
isQuestion
? _dto.copyWith(questionImage: copiedFile.path)
: _dto.copyWith(answerImage: copiedFile.path);
? _dto.copyWith(questionImage: destinationPath)
: _dto.copyWith(answerImage: destinationPath);
});
}