feature(image): Добавлен редактор фото
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user