openGaleryOnw2 method

dynamic openGaleryOnw2()

Implementation

openGaleryOnw2() {
  final ImagePickerPlatform _pickerAndroid = ImagePickerPlatform.instance;

  MultiImagePickerOptions options = MultiImagePickerOptions(
      limit: widget.maxPick! < 2 ? null : widget.maxPick);



  if (widget.cameraPick == CameraPick.video) {
    _pickerAndroid
        .getVideo(
        source: ImageSource.gallery,
        maxDuration: Duration(seconds: timeEnd))
        .then((onValue) {
      if (onValue != null) {
        File fileVideo = File(onValue.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! < 2){
      ImagePickerOptions optionspick = ImagePickerOptions();

      _pickerAndroid.getImageFromSource(source: ImageSource.gallery,options: optionspick).then((onValue){
        if (onValue != null){
          List<ImageModulModel> imageSelected = [];
          imageSelected.add(ImageModulModel(file: File(onValue.path)));
          gotPreview(imageSelected, FileType.image,onCallNot: openGaleryOnw2);
        }
      });
    }else{
      _pickerAndroid.getMultiImageWithOptions(options: options).then((onValue) {
        if (onValue.isNotEmpty) {
          List<ImageModulModel> imageSelected = [];

          onValue.forEach((action) {
            imageSelected.add(ImageModulModel(file: File(action.path)));
          });

          gotPreview(imageSelected, FileType.image, onCallNot: openGaleryOnw2);
        }
      });
    }

  }
}