enhanceCreatorParams method
- {required BuildContext context,
- required WidgetRef ref,
- required AppModel appModel,
- required CreatorModel creatorModel,
- required EnhancementTriggerCause cause}
override
Perform a change to the CreatorModel, executing the functionality of this enhancement. An EnhancementTriggerCause may be used to modify the behavior of the enhancement's function depending on whether the enhancement is being executed on auto, manual or cascade modes.
Implementation
@override
Future<void> enhanceCreatorParams({
required BuildContext context,
required WidgetRef ref,
required AppModel appModel,
required CreatorModel creatorModel,
required EnhancementTriggerCause cause,
}) async {
ImageExportField imageField = field as ImageExportField;
String? searchTerm;
File? imageFile = imageField.exportFile?.file;
if (imageFile == null) {
return;
}
Directory appDirDoc = await getApplicationSupportDirectory();
String cropImagePath = '${appDirDoc.path}/copyCrop';
Directory cropImageDir = Directory(cropImagePath);
if (cropImageDir.existsSync()) {
cropImageDir.deleteSync(recursive: true);
}
cropImageDir.createSync(recursive: true);
String timestamp = DateFormat('yyyyMMddTkkmmss').format(DateTime.now());
File copyFile = File('$cropImagePath/$timestamp');
imageFile.copySync(copyFile.path);
await showDialog<File?>(
context: context,
builder: (context) => CropImageDialogPage(
imageFile: copyFile,
onCrop: (file) {
imageField.setImages(
cause: cause,
appModel: appModel,
creatorModel: creatorModel,
newAutoCannotOverride: false,
searchTerm: searchTerm,
generateImages: () async {
return [NetworkToFileImage(file: file)];
},
);
},
),
);
}