项目作者: rodydavis

项目描述 :
File.io for Web, Desktop and Mobile for Flutter
高级语言: Dart
项目地址: git://github.com/rodydavis/file_access.git
创建时间: 2020-03-18T00:26:02Z
项目社区:https://github.com/rodydavis/file_access

开源协议:Other

下载


file_access

An abstract way to handle files on iOS, Android, Desktop and Web!

Online Demo: https://rodydavis.github.io/file_access/

Installing:

  1. dependencies:
  2. flutter:
  3. sdk: flutter
  4. file_access:
  5. git: https://github.com/rodydavis/file_access

Setup

Web

Add the following line to your body to make it work in Safari:

  1. <input type="file" style="visibility:hidden;" id="file-picker" />

IOS

https://github.com/miguelpruivo/flutter_file_picker/wiki/Setup#ios

Getting Started

Pick a file:

  1. final _file = await openFile();

Select multiple files:

  1. final _files = await openFiles();

Pick an image:

  1. final _file = await pickImage();

Pick a video:

  1. final _file = await pickVideo();

Once you have the FileX type you can read the data:

  1. final _bytes = await _file.readAsBytes();
  2. final _string = await _file.readAsString();

Creating a new file:

  1. final _file = FileX('path/to/file/file.txt');
  2. await _file.writeAsString('My New Data!');
  3. final _output = await _file.readAsString();
  4. print(_output); // 'My New Data!'