openGaleryWKWKImagePicker method
dynamic
openGaleryWKWKImagePicker(
- CameraPick cameraPick
)
Implementation
openGaleryWKWKImagePicker(CameraPick cameraPick) async {
final ImagePicker picker = ImagePicker();
if (cameraPick == CameraPick.video) {
final imagelll = await picker.pickVideo(source: ImageSource.gallery);
if (imagelll != null) {
File fileVideo = File(imagelll.path);
SellonRouter.push(
context,
VideoPreviewFileNew(
timeEnd: timeEnd,
key: widget.key!,
videoFile: fileVideo,
isFromCamera: false,
onDone: (filevideo){
SellonRouter.replace(context, VideoPreviewFile(
videoFileMov: filevideo,
key: widget.key,
videoFile: filevideo,
isFromCamera: false,
onDone: (valuelist){
widget.backVideo!(valuelist);
},
));
},
)).then((value) {
if (value == null) {
// openGaleryWKWKImagePicker(CameraPick.video);
} else {
if (value is List) {
widget.backVideo!(value);
}
}
});
}
} else {
if (widget.maxPick != null && widget.maxPick! > 1) {
// final imagelist = await picker.pickMultipleMedia(limit: widget.maxPick);
final imagelist = await picker.pickMultiImage(limit: widget.maxPick);
if (imagelist.length > widget.maxPick!) {
Ui(Config.navigatorKey.currentContext!).errorAlert(
message: "You Can't pick more than ${widget.maxPick}");
Future.delayed(Duration(seconds: 1)).then((value) {
openGaleryWKWKImagePicker(cameraPick);
});
} else {
List<ImageModulModel> imagelistending = [];
imagelist.forEach((element) {
imagelistending.add(ImageModulModel(file: File(element.path)));
});
if (imagelist.isNotEmpty) {
gotPreview(imagelistending, FileType.image,
onCallNot: openGaleryWKWKImagePicker(cameraPick));
}
}
} else {
final image = await picker.pickImage(source: ImageSource.gallery);
if (image != null) {
List<ImageModulModel> imagelist = [];
imagelist.add(ImageModulModel(file: File(image.path)));
if (imagelist.isNotEmpty) {
gotPreview(imagelist, FileType.image, onCallNot: openGaleryWKWKImagePicker(cameraPick));
}
}
}
}
// final XFile? image = await picker.pickImage(source: ImageSource.gallery);
}