Viewing version 0.3.2. Open the latest package page.
cross_file
0.3.2An abstraction to allow working with files across multiple platforms.
Readme
cross_file
An abstraction to allow working with files across multiple platforms.
Usage
Import package:cross_file/cross_file.dart, instantiate a XFile
using a path or byte array and use its methods and properties to
access the file and its metadata.
Example:
import 'package:cross_file/cross_file.dart';
final file = XFile('assets/hello.txt');
print('File information:');
print('- Path: ${file.path}');
print('- Name: ${file.name}');
print('- MIME type: ${file.mimeType}');
final fileContent = await file.readAsString();
print('Content of the file: ${fileContent}'); // e.g. "Moto G (4)"
You will find links to the API docs on the pub page.
Web Limitations
XFile on the web platform is backed by Blob
objects and their URLs.
It seems that Safari hangs when reading Blobs larger than 4GB (your app will stop without returning any data, or throwing an exception).
This package will attempt to throw an Exception before a large file is accessed
from Safari (if its size is known beforehand), so that case can be handled
programmatically.
Browser compatibility
Changelog
0.3.2
- Improve web implementation so it can stream larger files.
0.3.1+5
- Unify XFile interface for web and mobile platforms
0.3.1+4
- The
dart:ioimplementation ofsaveTonow does a file copy for path-basedXFileinstances, rather than reading the contents into memory.
0.3.1+3
- Fix example in README
0.3.1+2
- Fix package import in README
- Remove 'Get Started' boilerplate in README
0.3.1+1
- Rehomed to
flutter/packagesrepository.
0.3.1
- Fix nullability of
XFileBase'spathandnameto match the implementations to avoid potential analyzer issues.
0.3.0
- Migrated package to null-safety.
- breaking change According to our unit tests, the API should be backwards-compatible. Some relevant changes were made, however:
- Web:
lastModifiedreturns the epoch time as a default value, to maintain theFuture<DateTime>return type (and notnull)
- Web:
0.2.1
- Prepare for breaking
package:httpchange.
0.2.0
- breaking change Make sure the
saveTomethod returns aFutureso it can be awaited and users are sure the file has been written to disk.
0.1.0+2
- Fix outdated links across a number of markdown files (#3276)
0.1.0+1
- Update Flutter SDK constraint.
0.1.0
- Initial open-source release.
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add 'cross_file:0.3.2'pubspec.yaml
name: cross_file
description: An abstraction to allow working with files across multiple platforms.
repository: https://github.com/flutter/packages/tree/master/packages/cross_file
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+cross_file%22
version: 0.3.2
environment:
sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.22.0"
dependencies:
flutter:
sdk: flutter
js: ^0.6.3
meta: ^1.3.0
dev_dependencies:
flutter_test:
sdk: flutter
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.1.0 | Cached · Upstream SHA-256 matched | Download | 689ed0a6…2f83b7 |
| 0.2.0 | Cached · Upstream SHA-256 matched | Download | 96bea5b8…3184a1 |
| 0.2.1 | Cached · Upstream SHA-256 matched | Download | 13cb37fd…b44b8a |
| 0.3.0-nullsafety | Cached · Upstream SHA-256 matched | Download | 6bac36c5…1ad15b |
| 0.3.0 | Cached · Upstream SHA-256 matched | Download | f46f215b…d3cccb |
| 0.3.1 | Cached · Upstream SHA-256 matched | Download | 459de606…3d3f95 |
| 0.3.1+1 | Cached · Upstream SHA-256 matched | Download | 2ae7cae8…85a604 |
| 0.3.1+3 | Cached · Upstream SHA-256 matched | Download | e765bf84…5a27af |
| 0.3.1+4 | Cached · Upstream SHA-256 matched | Download | 437b2b8d…991068 |
| 0.3.1+5 | Cached · Upstream SHA-256 matched | Download | 5388c401…e44da4 |
| 0.3.2 | Cached · Upstream SHA-256 matched | Download | 552ffd2f…27a0fa |
| 0.3.3 | Cached · Upstream SHA-256 matched | Download | 93ccb9d2…242f0f |
| 0.3.3+1 | Cached · Upstream SHA-256 matched | Download | 7632a2bc…2a3d4f |
| 0.3.3+2 | Cached · Upstream SHA-256 matched | Download | f7107997…fb843b |
| 0.3.3+3 | Cached · Upstream SHA-256 matched | Download | b1c29cf7…e760d5 |
| 0.3.3+4 | Cached · Upstream SHA-256 matched | Download | 0b0036e8…8695e9 |
| 0.3.3+5 | Cached · Upstream SHA-256 matched | Download | fd832b53…dee2cb |
| 0.3.3+6 | Cached · Upstream SHA-256 matched | Download | 445db18d…d2142c |
| 0.3.3+7 | Cached · Upstream SHA-256 matched | Download | 2f9d2cbc…3882c5 |
| 0.3.3+8 | Cached · Upstream SHA-256 matched | Download | fedaadfa…1b9a5e |
| 0.3.4 | Cached · Upstream SHA-256 matched | Download | 74a4727e…a1fa40 |
| 0.3.4+1 | Cached · Upstream SHA-256 matched | Download | 55d7b444…945b32 |
| 0.3.4+2 | Cached · Upstream SHA-256 matched | Download | 7caf6a75…0d5670 |
| 0.3.5 | Cached · Upstream SHA-256 matched | Download | 942a4791…f16239 |
| 0.3.5+1 | Cached · Upstream SHA-256 matched | Download | 701dcfc0…996608 |
| 0.3.5+2 | Cached · Upstream SHA-256 matched | Download | 28bb3ae5…7c5937 |
| 0.3.5+3 | Cached · Upstream SHA-256 matched | Download | d687bec9…95024e |
| 0.3.5+4 | Cached · Upstream SHA-256 matched | Download | 92c9c43c…555c51 |
| 0.3.5+5 | Cached · Upstream SHA-256 matched | Download | f141ea4f…437bd6 |
| 0.4.0 | Cached · Upstream SHA-256 matched | Download | 3bde17bc…3d3fa4 |
Dependencies
flutter {
"sdk": "flutter"
}
js "^0.6.3"
meta "^1.3.0"