asset_copy 0.0.1 copy "asset_copy: ^0.0.1" to clipboard
asset_copy: ^0.0.1 copied to clipboard

The Asset Copy Plugin allows you to copy files from the Flutter app's assets to the device's local file system on both Android and iOS. This is useful when you need to manipulate or access large files [...]

example/lib/main.dart

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

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _statusMessage = 'Copying asset...';

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

  Future<void> copyAssetToLocal() async {
    String status;
    try {
      const assetName = 'example.json';
      const targetPath = 'example.json';

      await AssetCopy.copyAssetToLocalStorage(assetName, targetPath);
      status = 'File copied successfully to $targetPath';
    } on PlatformException catch (e) {
      status = 'Failed to copy asset: ${e.message}';
    }

    if (!mounted) return;

    setState(() {
      _statusMessage = status;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text(_statusMessage),
        ),
      ),
    );
  }
}
0
likes
140
points
25
downloads

Publisher

unverified uploader

Weekly Downloads

The Asset Copy Plugin allows you to copy files from the Flutter app's assets to the device's local file system on both Android and iOS. This is useful when you need to manipulate or access large files that are bundled within your Flutter app, such as JSON files, images, or other resources.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, path_provider, plugin_platform_interface

More

Packages that depend on asset_copy