open_document

Creator: coderz1093

Last updated:

Add to Cart

Description:

open document

open_document #
Used to create a folder on the user's mobile phone and Desktop;

Android stays inside documents with the name of your app
iOs is in your app's name files
Windows Documents


Opening pdf, xlsx, docs, ppt and zip files #

Getting Started #
Android ->> config res -> create folder -> xml -> create provider_paths.xml
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path
name="external_files"
path="." />
</paths>
copied to clipboard

Add AndroidManifest :
<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" />

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.example.open_document_example.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
copied to clipboard

iOs config -> info.plist Add
Create folder em Document
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
copied to clipboard
USED -> #
final name = await OpenDocument.getNameFile(url: url);

final path = await OpenDocument.getPathDocument();

filePath = "$path/$name";

final isCheck = await OpenDocument.checkDocument(filePath: filePath);

try {
if (!isCheck) {
filePath = await downloadFile(filePath: "$filePath", url: url);
}

await OpenDocument.openDocument(filePath: filePath);

} on OpenDocumentException catch (e) {
debugPrint("ERROR: ${e.errorMessage}");
filePath = 'Failed to get platform version.';
}

Future<String> downloadFile({String filePath, String url}) async {
// CancelToken cancelToken = CancelToken();
Dio dio = new Dio();
await dio.download(
url,
filePath,
onReceiveProgress: (count, total) {
debugPrint('---Download----Rec: $count, Total: $total');
setState(() {
_platformVersion = ((count / total) * 100).toStringAsFixed(0) + "%";
});
},
);

return filePath;
}
copied to clipboard
How to access the folder created with the files and view and delete: #
With StyleFile you can change some settings
of Viewing Your Screen with Your Files
StyleMyFile.elevatedButtonText = "Compartilhar"; #
Call preview screen

pushScreen() async {
String name = await OpenDocument.getNameFolder();

Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => MyFilesScreen(filePath: name),
),
);
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.