# cross_file 0.3.3+7

An abstraction to allow working with files across multiple platforms.




## Installing
```
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add 'cross_file:0.3.3+7'
```
Published: 2023-11-22T20:15:57.375871Z
Expected archive SHA-256: 2f9d2cbccb76127ba28528cb3ae2c2326a122446a83de5a056aaa3880d3882c5

Available in cache; verification: upstream_checksum
## Direct dependencies
- js: ^0.6.3
- meta: ^1.3.0

## Package README (untrusted upstream documentation)
# 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:

<?code-excerpt "example/lib/readme_excerpts.dart (Instantiate)"?>
```dart
final XFile file = XFile('assets/hello.txt');

print('File information:');
print('- Path: ${file.path}');
print('- Name: ${file.name}');
print('- MIME type: ${file.mimeType}');

final String fileContent = await file.readAsString();
print('Content of the file: $fileContent');
```

You will find links to the API docs on the [pub page](https://pub.dev/packages/cross_file).

## Web Limitations

`XFile` on the web platform is backed by [Blob](https://api.dart.dev/be/180361/dart-html/Blob-class.html)
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

[![Data on Global support for Blob constructing](https://caniuse.bitsofco.de/image/blobbuilder.png)](https://caniuse.com/blobbuilder)

[![Data on Global support for Blob URLs](https://caniuse.bitsofco.de/image/bloburls.png)](https://caniuse.com/bloburls)

## Testing

This package supports both web and native platforms. Unit tests need to be split
in two separate suites (because native code cannot use `dart:html`, and web code
cannot use `dart:io`).

When adding new features, it is likely that tests need to be added for both the
native and web platforms.

### Native tests

Tests for native platforms are located in the `x_file_io_test.dart`. Tests can
be run  with `dart test`.

### Web tests

Tests for the web platform live in the `x_file_html_test.dart`. They can be run
with `dart test -p chrome`.

## Changelog
## 0.3.3+7

* Updates README to improve example of instantiating an XFile.
* Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.

## 0.3.3+6

* Improves documentation about ignored parameters in IO implementation.

## 0.3.3+5

* Adds pub topics to package metadata.
* Updates minimum supported SDK version to Flutter 3.7/Dart 2.19.

## 0.3.3+4

* Reverts an accidental change in a constructor argument's nullability.

## 0.3.3+3

* **RETRACTED**
* Updates code to fix strict-cast violations.
* Updates minimum SDK version to Flutter 3.0.

## 0.3.3+2

* Fixes lint warnings in tests.
* Dartdoc correction for `readAsBytes` and `readAsString`.

## 0.3.3+1

* Fixes `lastModified` unimplemented error description.

## 0.3.3

* Removes unused Flutter dependencies.

## 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:io` implementation of `saveTo` now does a file copy for path-based
  `XFile` instances, 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/packages` repository.

## 0.3.1

* Fix nullability of `XFileBase`'s `path` and `name` to 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: `lastModified` returns the epoch time as a default value, to maintain the `Future<DateTime>` return type (and not `null`)

## 0.2.1

* Prepare for breaking `package:http` change.

## 0.2.0

* **breaking change** Make sure the `saveTo` method returns a `Future` so 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](https://github.com/flutter/plugins/pull/3276))

## 0.1.0+1

* Update Flutter SDK constraint.

## 0.1.0

* Initial open-source release.







 
