Comments (4)
I am keep getting this error:
Error:
flutter: ================= File: '/private/var/mobile/Containers/Data/Application/DBE50ECE-D66A-48C6-A1C3-1A15F602B300/tmp/image_crop_A2D9CA93-B387-4DE8-8269-E7CB040422F6-325-00000008F9BEEB4D.jpg'
flutter: Another exception was thrown: FileSystemException: Cannot open file, path = '/var/mobile/Containers/Data/Application/DBE50ECE-D66A-48C6-A1C3-1A15F602B300/Documents/File: '/private/var/mobile/Containers/Data/Application/DBE50ECE-D66A-48C6-A1C3-1A15F602B300/tmp/image_crop_A2D9CA93-B387-4DE8-8269-E7CB040422F6-325-00000008F9BEEB4D.jpg'' (OS Error: No such file or directory, errno = 2)
Code:
//TODO: CROP IMAGE
Future<void> _cropImage(BuildContext context) async {
final scale = cropKey.currentState.scale;
final area = cropKey.currentState.area;
if (area == null) {
// cannot crop, widget is not setup
return;
}
// scale up to use maximum possible number of pixels
// this will sample image in higher resolution to make cropped image larger
final sample = await ImageCrop.sampleImage(
file: _file,
preferredSize: (3000 / scale).round(),
);
final file = await ImageCrop.cropImage(
file: sample,
area: area,
);
print("================= $file");
setState(() {
IDCardClass.frontImageFile = file.toString();
widget.notifyParentFront();
_corrping = false;
});
Navigator.pop(context);
from image_crop.
my main page widget widget.notifyParentFront(); code:
// TODO: (5) REFRESH FRONT
refreshFront() async {
final _directory = await getApplicationDocumentsDirectory();
_appDocumentsDirectory = _directory.path;
setState(() {
if (IDCardClass.frontImageFile == null) {
print("IDCardClass.frontImageFile looks like null");
_frontImageFile = null;
} else {
//FILE
_frontImageFile = new File(
"${_appDocumentsDirectory + "/" + IDCardClass.frontImageFile}");
}
});
}
from image_crop.
This is not a right place for dart questions.
- The issue you are having is that you are not using right path of the file:
IDCardClass.frontImageFile = file.toString();
. Instead oftoString
you should be usingpath
property. That's assuming thatIDCardClass.frontImageFile
is aString
. - Once you cropped an image via
ImageCrop.cropImage
, it returns a file in the application directory. The application must have write permissions to local storage to copy this file to its final destination.
from image_crop.
I added the following code to solve the problem where the “ FileSystemException: Cannot open file”
Future.delayed(Duration(milliseconds: 200)).then((value) {
sample.delete();
croppedFile.delete();
});
参考 https://gitee.com/imboy-pub/imboy-flutter/blob/main/lib/component/helper/crop_image.dart
Future<void> _crop(File originalFile) async {
final crop = cropKey.currentState;
final area = crop!.area;
if (area == null) {
//裁剪结果为空
print('裁剪不成功');
}
await ImageCrop.requestPermissions().then((value) async {
if (value) {
final sample = await ImageCrop.sampleImage(
file: originalFile,
preferredSize: widget.preferredSize,
);
final croppedFile = await ImageCrop.cropImage(
file: sample,
area: crop.area!,
);
upload(croppedFile);
Future.delayed(Duration(milliseconds: 200)).then((value) {
sample.delete();
croppedFile.delete();
});
} else {
upload(originalFile);
}
});
}
from image_crop.
Related Issues (20)
- not maintained anymore? HOT 1
- The class 'Drag' can't be used as a mixin because it's neither a mixin class nor a mixin. HOT 8
- Compability issue at Flutter 3.10, Dart 3.0 HOT 1
- Unclear License Format
- Seeking Input: Enabling Landscape Image Support using Cropper - Your Expertise Needed!
- Circular crop mask
- Ability to disable Crop inside square corner dragging HOT 2
- Feature request: Image rotation
- Ability to restrict dimensions like image must be of 360x360 after cropping HOT 2
- PlatformException(multiple_request, Cancelled by a second request, null, null)
- please add circle feature
- Image is not displayed when reselecting previously cropped image HOT 8
- When the screen is horizontal, the scale display picture is automatically enlarged
- How i can set cropping grid points mannually
- Flutter 3.0.0 warning HOT 1
- Module 'image_crop' not found HOT 1
- Crop bounds e rotate
- Poor quality during crop HOT 2
- Change of Copyright notice
- Not working with flutter 3.7.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from image_crop.