4

I am new on Flutter and trying to do an app that use camera. So, everything works fine and I am using image_picker lib. Now, I need to add a mask for my user to capture using this mask to position the document (like a overlay) but I can't find anywhere saying how to do that. Does anyone know if it's possible using this lib to do it?

Regards,

Gustavo Oka
  • 79
  • 1
  • 6

2 Answers2

3

I don't think the image_picker can do what you want to do.

Instead of that, you could use the Camera package and put your overlay and the preview of camera in a Stack widget

F Perroch
  • 1,988
  • 2
  • 11
  • 23
2

You can use package https://pub.dev/packages/camera_camera
It provide imageMask attribute
example code https://github.com/gabuldev/camera_camera/tree/master/example/lib
code snippet

Camera(
       mode: CameraMode.normal,
       imageMask: CameraFocus.rectangle(
                color: Colors.black.withOpacity(0.5),
                ),
     )

enter image description here

enter image description here

chunhunghan
  • 51,087
  • 5
  • 102
  • 120
  • 1
    At the moment, camera_camera version 2.0.0 has removed the mask option from its build. Older versions can still work, but they have some issues with null-safety that may result in incompatible dependencies. – il_boga Mar 17 '21 at 14:26