A Flutter project to open device's camera to capture image or video (or you can pick image on Android platform) and get the file's path and the file's type on Android and iOS platforms.


Paste the following attribute in the manifest tag in the AndroidManifest.xml


For example:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="your package...">

Add these permissions to your AndroidManifest.xml

    <uses-feature android:name="android.hardware.camera.any"
        android:required="true" />
    <uses-feature android:name="android.hardware.camera.autofocus"
        android:required="false" />
    <uses-permission android:name="android.permission.CAMERA"  
        android:requiredFeature="true" />

    <uses-permission android:name="android.permission.FLASHLIGHT" />
    <uses-feature android:name="android.hardware.camera.flash" android:required="false"
        tools:targetApi="eclair" />

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

Create xml folder in android/app/src/main/res (for example: file_paths.xml) and add the lines below to the created xml file

<?xml version="1.0" encoding="utf-8"?>
        path="." />

After create your own file provider and define your own path paste them into this and add to your AndroidManifest.xml

<provider android:name="androidx.core.content.FileProvider"
          android:exported="false" android:grantUriPermissions="true">
    <meta-data android:name="android.support.FILE_PROVIDER_PATHS" 
               android:resource="@xml/[your_custom_fileProvider_file_name]" />


Add these lines to your Info.plist file

<string>Our app needs permission to access the camera</string>

<string>$(PRODUCT_NAME) needs permission to access the microphone to record the audio along with the video</string>

<string>$(PRODUCT_NAME) needs permission to save photo to your gallery</string>

<string>$(PRODUCT_NAME) needs permission to access your photos</string>



How to use

  • Simply call openNativeCamera method from LecleNativeCamera class to open the native camera to capture video or image (or you can pick image on Android platform) and the method will return the path of the captured file and the type of the file.
  • The return data will be converted into a FileData object and you can use this object to get the file's path and the file's type easily.


The properties in the openNativeCamera method and platform that the platform they work on

Properties Android iOS
fileProviderPath X
imageExtension X X
videoExtension X X
fileName X X
androidOptionSheetTitle X
canPickFile X
videoQuality X X
imageQuality X X
imageWidth X
imageHeight X
customSaveFolder X
saveFolder X


    onPressed: () {
        fileProviderPath: 'your_custom_fileProvider_path', // This must be the same with the custom path that you defined in the AndroidManifest file
        imageExtension: ImageExtension.jpeg,
        videoQuality: VideoQuality.typeHigh,
        videoExtension: VideoExtension.mov,
        imageQuality: 100,
        imageWidth: 2160,
        imageHeight: 3804,
        androidOptionSheetTitle: 'your_custom_title',
        canPickFile: true,
        fileName: 'your_custom_file_name',
        customSaveFolder: 'Test Folder',
        (value) async {
          if (value != null) {
            if (value.fileType == FileType.image &&
                value.filePath != null) {
              setState(() {
                imageFile = File(value.filePath!);
                imageFile!.length().then((value) {
                  print('File size ::: $value');
                videoFile = null;
                _controller = null;
            } else if (value.fileType == FileType.video &&
                value.filePath != null) {
              setState(() {
                videoFile = File(value.filePath!);
                videoFile!.length().then((value) {
                  print('File size ::: $value');
                imageFile = null;
                _controller = VideoPlayerController.file(videoFile!);
                      (value) {
                    setState(() {});
                    _controller!.addListener(() {
                      if (_controller?.value.position ==
                          _controller?.value.duration) {
                        setState(() {
                          _isPlaying = false;
    child: const Text('Open native camera'),