document_file_save 1.0.3 copy "document_file_save: ^1.0.3" to clipboard
document_file_save: ^1.0.3 copied to clipboard

Save bytes data into Download folder (Android), or show save dialog (iOS).

example/lib/main.dart

import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:convert';
import 'package:flutter/services.dart';
import 'package:document_file_save/document_file_save.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  @override
  void initState() {
    super.initState();

    List<int> htmlBytes = utf8.encode("<h1>Header 1</h1><p>This is sample text</p>");
    List<int> textBytes = utf8.encode("Some data");

    // save multiple files
    DocumentFileSave.saveMultipleFiles([htmlBytes, textBytes], ["htmlfile.html", "textfile.txt"], ["text/html", "text/plain"]);

    // save multiple files (case that file have same name). system will automatically append number to filename.
    //DocumentFileSave.saveMultipleFiles([htmlBytes, textBytes], ["file.txt", "file.txt"], ["text/html", "text/plain"]);

    // save single file
    // DocumentFileSave.saveFile(htmlBytes, "my test html file.html", "text/html");
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('document_file_save Plugin'),
        ),
        body: Center(
          child: Text('Please check file in Download folder (or Files App in iOS)'),
        ),
      ),
    );
  }

}
6
likes
40
pub points
26%
popularity

Publisher

unverified uploader

Save bytes data into Download folder (Android), or show save dialog (iOS).

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on document_file_save