i am using image_picker: ^1.0.4 package for picking image from camera and gallery. it is working fine for android and ios but in windows camera is not opening. documentation suggests that to use custom camera delegate. i tried to put things together but nothing worked.
final pickedFile = await ImagePicker().getImage(
source: ImageSource.camera,
);
I tried following piece of codes
import 'package:image_picker_platform_interface/image_picker_platform_interface.dart';
// ···
class MyCameraDelegate extends ImagePickerCameraDelegate {
@override
Future<XFile?> takePhoto(
{ImagePickerCameraDelegateOptions options =
const ImagePickerCameraDelegateOptions()}) async {
return _takeAPhoto(options.preferredCameraDevice);
}
@override
Future<XFile?> takeVideo(
{ImagePickerCameraDelegateOptions options =
const ImagePickerCameraDelegateOptions()}) async {
return _takeAVideo(options.preferredCameraDevice);
}
}
// ···
void setUpCameraDelegate() {
final ImagePickerPlatform instance = ImagePickerPlatform.instance;
if (instance is CameraDelegatingImagePickerPlatform) {
instance.cameraDelegate = MyCameraDelegate();
}
}
but still getting following issue
ImageSource.camera is not supported unless a cameraDelegate is set
if someone has working code then please guide what's wrong or share your implementation.