패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.1.3

media_store_plus

Flutter에서 Android MediaStore API를 사용하려면 Flutter를 통해 모든 Android 버전에서 읽기 및 쓰기 작업을 지원합니다.

Android
30일 다운로드
2.4만
좋아요
91
Pub 점수
160

패키지 설치

flutter pub add media_store_plus

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

media_store_plus는 모든 Android 버전에서 미디어 파일에 대한 읽기 및 쓰기 작업을 가능하게 하는 Flutter 패키지입니다. 이는 Flutter를 네이티브 Android 기능과 연결하여 시스템의 미디어 저장소를 통해 오디오, 비디오 및 이미지 파일을 직접 관리할 수 있도록 합니다. Android용 Flutter 앱과의 원활한 통합을 위해 설계되었으며, 플랫폼별 코드 없이 신뢰할 수 있는 파일 처리를 제공합니다. 일반적인 미디어 작업인 미디어 항목 쿼리, 삽입 및 업데이트를 지원합니다.

사용 사례

  • 장치 미디어 파일에 액세스
  • 사진 및 비디오 관리
  • 미디어 메타데이터 읽기 및 쓰기
  • Android 미디어 라이브러리와의 통합
  • 미디어 갤러리 앱 구축

주요 기능

  • 버전 간 안드로이드 호환성
  • 미디어 파일에 대한 읽기 및 쓰기 지원
  • 네이티브 Android MediaStore 통합
  • Simple Flutter API
  • 플랫폼 채널이 필요하지 않습니다

적합한 대상

  • 안드로이드 전용 미디어 관리
  • 미디어 갤러리 애플리케이션
  • 장치 저장소에서 파일 가져오기/내보내기
  • 직접 MediaStore에 접근이 필요한 앱

고려 사항

  • Android 플랫폼에 한정
  • 적절한 런타임 권한이 필요합니다
  • 권한 요청 처리가 필요할 수 있습니다
  • Android SDK 버전 호환성에 의존

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

media_store_plus

To use Android MediaStore API in Flutter. It supports both read & write operations in every Android version through Flutter. It also requests appropriate permissions, if needed.

Motivation

From API level 30, we have to use Scoped Storage to write files. Though, we can read all files by direct path until API level 32, from API level 33 we need to use Scoped Storage for reading also.

We can write in DCIM, Pictures, Movies, Alarms, Audiobooks, Music, Podcasts, Ringtones, and Download folders by MediaStore without any kind of Storage permission. You can also read without any permission from these folders as long as the files are created by the app. But if we uninstall the app, and install it again, then, it will lose the read/write access for the files previously created by the app.

Again, we can read all files by requesting android.permission.READ_EXTERNAL_STORAGE permission until API level 32.From API level 33, it has no usage. Android introduces three specific permissions i.e. android.permission.READ_MEDIA_IMAGES, android.permission.READ_MEDIA_AUDIO & android.permission.READ_MEDIA_VIDEO to read audio, video & images.

But, we can't read other folders from API level 33 without requesting explicit permission for those folders.

Sum up, from Flutter there is no way to write in any folder with/without storage permission other than the app data folder!

Because, we can't use the MediaStore API from Flutter, that is required for writing, other than the app data folder. Again we can't request to read/write any specific folder using a file picker from Flutter.

So, the only solution is to use the platform channel for this. This issue led me to create this media_store_plus plugin.

Usage

You can read, write, edit, and delete in the DCIM, Pictures, Movies, Alarms, Audiobooks, Music, Podcasts, Ringtones, Download with this plugin. You can also request to read or write any specific folder other than those mentioned above, by file picker with this plugin. Again when you try to read, edit, or delete a file that is not created by your app, it will automatically request permission from the user for that task.

You can read the full documentation from here. You can also check the example app for implementation. Reading the plugin's source code also helps you in that case.

Getting Started

First, add media_store_plus as a dependency in your pubspec.yaml file.

dependencies:
  media_store_plus: ^0.1.3

Don't forget to flutter pub get.

Android Side

Edit the AndroidManifest.xml like this.

    <!-- required from API level 33 -->
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" /> <!-- To read images created by other apps -->
    <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" /> <!-- To read audios created by other apps -->
    <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" /> <!-- To read vidoes created by other apps -->

    <uses-permission
        android:name="android.permission.READ_EXTERNAL_STORAGE" <!-- To read all files until API level 32 -->
        android:maxSdkVersion="32" />

    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE" <!-- To write all files until API level 29. We will MediaStore from API level 30 -->
        android:maxSdkVersion="29" />

    <application
        ---------------------------
        android:requestLegacyExternalStorage="true"> 
        <!-- Need for API level 29. Scoped Storage has some issue in Android 10. So, google recommanded to add this. -->
        <!-- Read more from here: https://developer.android.com/training/data-storage/shared/media#access-other-apps-files-->
    </application>

You need to modify the proguard-rules.pro file as per this link. Because this plugin uses GSON internally.

Contribution

You can create issue(s) for any missing feature(s) that is relevant to this plugin. You can also help by pointing out any bugs. Pull requests are also welcomed

Status

This is an active project as MediaStore is the future of accessing files in Android. There's a lot of room to improve this plugin.

Support the package (optional)

If you find this package useful, you can support it by giving it a star.

Credits

This package is developed by Shahriar Nasim Nafi

카테고리

의존성

의존성 목록 2 개

  • meta^1.8.0
  • plugin_platform_interface^2.0.2

소스 저장소

이 패키지를 사용하는 프로젝트