Closed rahatcse5bu closed 3 months ago
If you want to get the bytes even if the user didn't change anything, you can set the config allowCompleteWithEmptyEditing
to true which will always return the bytes when the user presses done.
return ProImageEditor.network(
'https://picsum.photos/id/237/2000',
allowCompleteWithEmptyEditing: true,
...
);
If you need more callbacks, you can use the dev version pro_image_editor: ^3.0.0-dev.26
, which has many more callbacks and configuration options.
in "^3.0.0-dev.26" version, i can't find allowCompleteWithEmptyEditing: true
In the dev version, this option is now true by default. If you still want to change it, you can do so as follows:
return ProImageEditor.network(
'https://picsum.photos/id/110/2000',
callbacks: ProImageEditorCallbacks(
/// Some callbacks like onImageEditingComplete
),
configs: ProImageEditorConfigs(
imageGenerationConfigs: ImageGeneratioConfigs(
allowEmptyEditCompletion: true,
),
),
);
You can also check out the examples here which show you full code examples.
last question please: for the version, pro_image_editor : ^2.4.3, is there any options I want?
Unfortunately, no, this old version does not support a way that you want. If you really need this old version, you have to do this part by yourself. Below is an example of how to do it:
Uint8List? resultBytes;
String assetPath = ExampleConstants.of(context)!.demoAssetPath;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ProImageEditor.asset(
assetPath,
onImageEditingComplete: (bytes) async {
resultBytes = bytes;
Navigator.pop(context);
},
),
),
).whenComplete(() async {
if (resultBytes == null) {
// Load the asset as a ByteData
final ByteData data = await rootBundle.load(assetPath);
// Convert the ByteData to a Uint8List
resultBytes = data.buffer.asUint8List();
}
});
And here is a sample code where you can see how to convert all input formats like File
to Uint8List
.
Platforms
Android, iOS, Web, Windows, macOS, Linux
Description
Now OnEditImageCompleted works only if I interact with the image(add/edit anything). But I want OnEditImageCompleted callback or similar mechanism when the user doesn't need any editing and click on "done" icon , and it should have a callback/void function that catches the Uint8List bytes, I want to get the Uint8List bytes image data when no user edit is performed and the user click on the 'done' icon
Why
No response