getPreferredCameraDevice property

GetPreferredCameraDevice? getPreferredCameraDevice
final

Called when the user clicks the addImageIcon and getImageSource is ImageSource.camera.

If null by default CameraDevice.rear will be used.

Add the required camera permission in your OS files to use Camera

Example:

getPreferredCameraDevice: () {
  return showDialog<CameraDevice>(
    context: context,
    builder: (context) {
      return SimpleDialog(
        children: [
          SimpleDialogOption(
            child: const Text("Rear"),
            onPressed: () {
              Navigator.of(context).pop(CameraDevice.rear);
            },
          ),
          SimpleDialogOption(
              child: const Text("Front"),
              onPressed: () {
                Navigator.of(context).pop(CameraDevice.front);
              }),
        ],
      );
    },
  ).then(
    (value) {
      return value ?? CameraDevice.rear;
    },
  );
},

Implementation

final GetPreferredCameraDevice? getPreferredCameraDevice;