feature(image): Добавлен редактор фото
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -184,6 +184,7 @@ class _CrudCollectionFullscreenFieldState
|
||||
|
||||
void _onSubmitTap() {
|
||||
widget.onEditingComplete(_controller.text);
|
||||
|
||||
context.back();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user