skipped image cropper funktion if it is already a 1:1 image, plugin for logging
This commit is contained in:
+20
-1
@@ -65,10 +65,28 @@ class _AddScreenState extends State<AddScreen> {
|
|||||||
final tempFile = File(pickedFile.path);
|
final tempFile = File(pickedFile.path);
|
||||||
final bool isValid = await isFileSizeValid(tempFile, 10);
|
final bool isValid = await isFileSizeValid(tempFile, 10);
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
File croppedFile = await _cropImage(tempFile); // Bild zuschneiden
|
// Bildinformationen lesen
|
||||||
|
final originalImage = img.decodeImage(await tempFile.readAsBytes());
|
||||||
|
|
||||||
|
if (originalImage != null) {
|
||||||
|
if (originalImage.width == originalImage.height) {
|
||||||
|
// Wenn das Bild bereits im 1:1-Format ist, überspringen Sie das Zuschneiden
|
||||||
|
setState(() {
|
||||||
|
_imageFile = tempFile;
|
||||||
|
print("1:1");
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Wenn das Bild nicht im 1:1-Format ist, schneiden Sie es zu
|
||||||
|
File croppedFile = await _cropImage(tempFile);
|
||||||
setState(() {
|
setState(() {
|
||||||
_imageFile = croppedFile;
|
_imageFile = croppedFile;
|
||||||
});
|
});
|
||||||
|
print("decode");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw Exception('Unable to decode image file.');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(content: Text('Die Dateigröße darf maximal 10 MB betragen.')),
|
const SnackBar(content: Text('Die Dateigröße darf maximal 10 MB betragen.')),
|
||||||
@@ -78,6 +96,7 @@ class _AddScreenState extends State<AddScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Future<void> addNewElementToFirestore(String title, String description, File imageFile, {required Function(bool) onComplete}) async {
|
Future<void> addNewElementToFirestore(String title, String description, File imageFile, {required Function(bool) onComplete}) async {
|
||||||
String collectionName;
|
String collectionName;
|
||||||
if (_selectedIndex == 0) {
|
if (_selectedIndex == 0) {
|
||||||
|
|||||||
@@ -416,6 +416,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
version: "2.0.1"
|
||||||
|
logging:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: logging
|
||||||
|
sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.1"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ dependencies:
|
|||||||
pdf: ^3.10.1
|
pdf: ^3.10.1
|
||||||
printing: ^5.10.4
|
printing: ^5.10.4
|
||||||
image_cropper: ^3.0.3
|
image_cropper: ^3.0.3
|
||||||
|
logging: ^1.1.1
|
||||||
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|||||||
Reference in New Issue
Block a user