custom_save_pdf
Flutter 패키지는 전화 저장소의 사용자 지정 폴더에 PDF 파일을 저장할 수 있도록 허용합니다
Flutter 패키지는 휴대폰 저장소의 사용자 정의 폴더에 PDF 파일을 저장할 수 있도록 해줍니다.
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
Nasr Al-Rahbi @abom_me
custom_save_pdf: using the official open_document & path_provider & permission_handler.
| Android | iOS | |
|---|---|---|
| Support | SDK 29+ | iOS 11+ |
Pubspec changes:
dependencies:
custom_save_pdf: <last_verison>
Sample example:
import 'package:custom_save_pdf/custom_save_pdf.dart';
CustomPdfFolder.save(
byteList: data,
nameOfFolder: 'nasr',
openPDF: true,
onSaved: (v) {},
onError: (error, code) {
print(error);
print(code);
});
minSdkVersion in android/app/build.gradle :android {
defaultConfig {
minSdkVersion 29
}
}
2-You should make sure to set the correct compileSdkVersion in android/app/build.gradle :
android {
compileSdkVersion 33
...
}
3-Add this in android/app/build.gradle :
<!-- First add this -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
<!-- now add this line in application -->
android:requestLegacyExternalStorage="true"
...
>
<!-- add this code inside tag application -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="{the pakage of app}.{the app name}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
3- Go to android/app/src/main/res and create folder name it xml then create provider_paths.xml
<!-- Add this code in provider_paths.xml -->
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path
name="external_files"
path="." />
</paths>
1- add this code in info.plist:
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
See the example directory for a complete sample app.
/// <p style="color:#77b4ff;font-size:16;font-weight: bold;">---- EN ----</p>
/// ### Add The Uint8List From (PDF) Package
/// #### <a href="https://pub.dev/packages/pdf"> PDF Package </a>
/// #### <span style="color:green"> You Will find example in the document</span>
/// <p style="color:#77b4ff;font-size:16;font-weight: bold;">---- AR ----</p>
/// ### اضف كود
/// ### Uint8List
///### بإمكانك الحصول عليه من باكج
///### PDF
/// ### <a href="https://pub.dev/packages/pdf"> PDF Package </a>
/// #### <span style="color:green"> سوف تجد أمثلة في مستندات الباكج</span>
final Uint8List byteList;
/// <p style="color:#77b4ff;font-size:16;font-weight: bold;">---- EN ----</p>
///
/// ### Write Name for The folder, Where The PDF File Saving on it
///
/// <p style="color:#77b4ff;font-size:16;font-weight: bold;">---- AR ----</p>
/// ### أكتب أسم المجلد الذي تريد حفظ الملفات بداخله
final String nameOfFolder;
/// <p style="color:#77b4ff;font-size:16;font-weight: bold;">---- EN ----</p>
/// ### Write name for the file, for example:
/// #### (-- example.pdf --)
/// <span style="color:#d80000"> Without (.pdf) </span>
/// <br>
/// <span style="color:green">You can keep it empty and will make random name</span>
/// <p style="color:#77b4ff;font-size:16;font-weight: bold;">---- AR ----</p>
/// ### أكتب اسم للملف الذي تريد حفظه, مثال:
/// #### (-- example.pdf --)
/// <span style="color:#d80000"> بدون اضافة الامتداد (.pdf) </span>
/// <br>
/// <span style="color:green">بإمكانك تركه فارغا وسوف يقوم بإنشاء اسم عشوائي </span>
final String? fileName;
/// <p style="color:#77b4ff;font-size:16;font-weight: bold;">---- EN ----</p>
/// ### Here You can get the path of the pdf file as String
/// <p style="color:#77b4ff;font-size:16;font-weight: bold;">---- AR ----</p>
/// ### هنا يعطيك مسار الملف كنص
final void Function(String filePath)? onSaved;
/// <p style="color:#77b4ff;font-size:16;font-weight: bold;">---- EN ----</p>
/// ### Here showing you any error happen with the code of the error and you can add Function if there is any errors
/// <p style="color:#77b4ff;font-size:16;font-weight: bold;">---- AR ----</p>
/// ### هنا يظهر نص و رقم الخطأ اذا حدثت اي اخطاء، و بإمكانك إعطائه امر ليفعله اذا عثر على خطأ
final void Function(String error, int errorCode)? onError;
/// <p style="color:#77b4ff;font-size:16;font-weight: bold;">---- EN ----</p>
/// ### keep it true to open the pdf file after save it
/// ### or false to only saving in files
/// <span style="color:green;font-size:13;font-weight: bold;">it's True by default </span>
/// <p style="color:#77b4ff;font-size:16;font-weight: bold;">---- AR ----</p>
/// #### True
/// #### لكي ينفتح الملف بعد حفظه
/// #### False
/// #### لكي يحفظ الملف فقط بدون فتحه
bool? openPDF = true;
의존성 목록 7 개
^1.0.5^2.0.11^10.2.0{"sdk":"flutter"}{"sdk":"flutter"}^2.0.0^2.0.1사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗