large_file_handler 0.2.1 copy "large_file_handler: ^0.2.1" to clipboard
large_file_handler: ^0.2.1 copied to clipboard

The Large File Handler Plugin designed to efficiently work with large files, for example allows you to download large files from network or copy files from the Flutter app's assets to the device's loc [...]

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:large_file_handler/large_file_handler.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...';
  StreamSubscription<int>? _progressSubscription;

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

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

      Stream<int> progressStream = LargeFileHandler().copyAssetToLocalStorageWithProgress(
        assetName: assetName,
        targetPath: targetPath,
      );

      _progressSubscription = progressStream.listen(
        (progress) {
          setState(() {
            _statusMessage = 'Copying asset... $progress%';
          });
        },
        onDone: () {
          setState(() {
            _statusMessage = 'File copied successfully to $targetPath';
          });
        },
        onError: (error) {
          setState(() {
            _statusMessage = 'Failed to copy asset: $error';
          });
        },
      );
    } on PlatformException catch (e) {
      setState(() {
        _statusMessage = 'Failed to copy asset: ${e.message}';
      });
    }
  }

  @override
  void dispose() {
    _progressSubscription?.cancel();
    super.dispose();
  }

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

Publisher

unverified uploader

Weekly Downloads

The Large File Handler Plugin designed to efficiently work with large files, for example allows you to download large files from network or copy files from the Flutter app's assets to the device's local file system. This is useful when you need to access large files at native part in your plugins

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, path_provider, plugin_platform_interface

More

Packages that depend on large_file_handler