openCameraGallery method

void openCameraGallery()

Implementation

void openCameraGallery() async {
  try {
    showLoadingPermission();

    if (checkPermission == languageKey.lblCamera) {
      final ImagePicker pickerCamera = ImagePicker();
      XFile? image = await pickerCamera.pickImage(source: ImageSource.camera);
      _responseImage(image);
      return;
    }

    if (Platform.isAndroid) {
      final deviceInfo = await DeviceInfoPlugin().androidInfo;
      if (deviceInfo.version.sdkInt > 32) {
        filePickerPickFiles(multiSelect, allowedExtensions).
          then((value) => _responseFile(value)).
          onError((e, stackTrace) => _error(e)).catchError((e) => _error(e));
        return;
      }
    }

    RequestType type = RequestType.common;
    if (types != null && types!.length == 1) {
      switch (types![0]) {
        case 'image': type = RequestType.image; break;
        case 'video': type = RequestType.video; break;
        case 'audio': type = RequestType.audio; break;
        default: type = RequestType.all;
      }
    }
    final List<AssetEntity>? result = await AssetPicker.pickAssets(context, pickerConfig: AssetPickerConfig(
        requestType: type, maxAssets: maxSelect
    ));
    resetCheckPermission();
    if (result != null && result.isNotEmpty) _processAsset(result);
  } catch (_) {}
}