open_document 1.0.7 copy "open_document: ^1.0.7" to clipboard
open_document: ^1.0.7 copied to clipboard

OpenDocument generate a local folder, for file and document storage, also can open pdf, xlsx, docs, ppt and zip files. You can also locate your files by implementing MyFilesScreen you can change folde [...]

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>

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>

iOs config -> info.plist Add Create folder em Document

 <key>LSSupportsOpeningDocumentsInPlace</key>
    <true/>

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;
}

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),
    ),
  );
}

47
likes
130
points
812
downloads

Publisher

unverified uploader

Weekly Downloads

OpenDocument generate a local folder, for file and document storage, also can open pdf, xlsx, docs, ppt and zip files. You can also locate your files by implementing MyFilesScreen you can change folder styles and colors using StyleMyFile

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

archive, flutter, flutter_slidable, intl, plugin_platform_interface, share_plus

More

Packages that depend on open_document