Search code examples
androidiosflutterdartcamera

How to allow use of camera in the flutter application?


I am making an application that processes photos that the user selects, and I would like to put a "Allow use of the camera" option, just like Skype, Facetime, which need user permission to use the camera and microphone. How can I do this, and what should I add to "pubspec.yaml"?


Solution

  • To get the permission dialog to your app, you have to add:

    <uses-permission android:name="android.permission.CAMERA" />
    

    inside your AndroidManifest.xml file.

    And then, for the camera, you need at least 3 dependencies inside your pubspec.yaml file:

    camera Provides tools to work with the cameras on the device.

    path_provider Finds the correct paths to store images.

    path Creates paths that work on any platform.

    For more information, go to the official docs here.