process method
- FilePickerConfig config,
- FileWrapper file
override
method that is to be implemented.
Implementation
@override
Future<FileWrapper> process(FilePickerConfig config, FileWrapper file) async {
if (kIsWeb) return file;
if (file.isImage() && file.content != null) {
// ignore: avoid_dynamic_calls
final originalFile = File(file.content.path as String);
ImageEditor.i18n(ComponentStrings.of(buildContext.call()).getAll());
final bytes = await Navigator.of(buildContext.call(), rootNavigator: true).push<Uint8List>(
ZdsFadePageRouteBuilder(
fullscreenDialog: true,
builder: (context) {
return ImageCropper(
image: originalFile.readAsBytesSync(),
);
},
),
);
if (bytes != null) {
final dir = await zdsTempDirectory('edited');
await originalFile.delete(recursive: true);
final result = File(path.join(dir, path.basename(originalFile.absolute.path)));
await result.writeAsBytes(bytes);
return FileWrapper(file.type, ZdsXFile.fromFile(result));
}
}
return file;
}