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

@@ -5,6 +5,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';
@@ -76,9 +77,26 @@ class _CrudCollectionScreenState extends State<CrudCollectionScreen> {
}
final String fileName = path.basename(originPath!);
final String destinationPath = path.join(collectionsDirPath, fileName);
final String destinationPath = path.join(
collectionsDirPath,
'${DateTime.now()}$fileName',
);
await File(originPath).copy(destinationPath);
final croppedFile = await ImageCropper().cropImage(
sourcePath: originPath,
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);
_updateCollection(avatar: destinationPath);
} catch (e) {

View File

@@ -184,6 +184,7 @@ class _CrudCollectionFullscreenFieldState
void _onSubmitTap() {
widget.onEditingComplete(_controller.text);
context.back();
}