large_file_copy 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 71

large_file_copy #

Due to the fact that Flutter does not allow large file copies yet (at least that is what seems to be the case by January of 2019), I created this Plugin.

The following code is normally used to copy a small file from the assets folder to the App Documents folder where it can be used further...

Directory directory = await getApplicationDocumentsDirectory();
var dbPath = join(directory.path, "app.db");
if (FileSystemEntity.typeSync(dbPath) == FileSystemEntityType.notFound) {
  ByteData data = await rootBundle.load("assets/my_db_file.db");
  List<int> bytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
  await File(dbPath).writeAsBytes(bytes);

However, I found that the above code does not work for large files ! Therefore the motivation for this plugin (i.e. to make the file-copy natively for each platform).

The Plugin copies a large File natively ...

  • from the native-Bundle (iOS)...
  • from the assets-folder (Android)...

--> ...and places it to your Application Documents Folder

(of course, it does the copying only if the file does not already exist at the Application Documents Folder location [same name]).

The plugin method created is called copyLargeFile

The return-value of the copyLargeFile method delivers the fullNamePath of the copied (or already existing) large File inside the Application Documents Folder.

Getting Started (native preparations) #

The following preparation is needed as for the native worlds respectively. (i.e. in both worlds, you need to provide the large-file inside the corresponding native Bundle or Assets-folder...)


  • open your Flutter-project's /ios/Runner.xcworkspace in Xcode
  • inside Runner, create a new Group and call it for example "Bundle"
  • inside Bundle (or whatever you called your Group), drag and drop your large File (make sure to select "Copy items if needed")
  • (optional): to check if all is correct for iOS - go to your Flutter project's ios/Runner/ Folder and see if the added large File is there...


  • open your Flutter-project's /android/my_flutter_project_name_android.iml in Android Studio
  • inside app/app/src/main/assets/ folder drag and drop your large file (create assets folder if it is not already there)
  • (optional): to check if all is correct for Android - go to your Flutter project's android/src/main/assets/ Folder and see if the added large File is there...

How to use the large_file_copy Plugin inside your Flutter project #

1. Inside pubspec.yaml file of your Flutter project, add the following dependency: #

    sdk: flutter
  large_file_copy: ^0.0.1

(hint: the version might be different in the meantime. Make sure to include the newest version of the package plugin).

2. Import the package #

import 'package:large_file_copy/large_file_copy.dart';

3. Inside one of your StatefulWidget's State, use the large_file_copy plugin #

  void initState() {

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String fullPathName;

    try {
      platformVersion = await LargeFileCopy.platformVersion;
      fullPathName = await LargeFileCopy("testy.txt").copyLargeFile;
    } on PlatformException {
      print('Failed to copy the Large File.');

    if (!mounted) return;

    print(fullPathName); // this is the location of your large-file now. Use it for anything in your Flutter app.

4. you can now use your large File from the Application Documents folder #

The path to the file is given by the fullPathName return value of the native LargeFileCopy("myLargeFileName.db").copyDB method.

0.0.1 #

  • TODO: This is the first release of the large_file_copy plugin for Flutter


import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:large_file_copy/large_file_copy.dart';

void main() => runApp(MyApp());

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  void initState() {

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    try {
      platformVersion = await LargeFileCopy.platformVersion;
      String yep = await LargeFileCopy("testy.txt").copyLargeFile;
    } on PlatformException {
      print('Failed to copy the Large File.');
    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;

  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        body: Center(
          child: Text('Running on: $_platformVersion\n'),

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  large_file_copy: ^0.0.1

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:large_file_copy/large_file_copy.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Apr 4, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health issues and suggestions

Document public APIs. (-1 points)

6 out of 6 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/large_file_copy.dart.

Run flutter format to format lib/large_file_copy.dart.

Maintenance suggestions

Package is getting outdated. (-21.64 points)

The package was last published 63 weeks ago.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8