Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cross_file/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## NEXT
## 0.3.5+3

* Updates minimum supported SDK version to Flutter 3.38/Dart 3.10.

Expand Down
3 changes: 3 additions & 0 deletions packages/cross_file/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ final String fileContent = await file.readAsString();
print('Content of the file: $fileContent');
```

The `mimeType` property is not inferred from the file path or contents. It is
only available if provided when the `XFile` was created.

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

## Web Limitations
Expand Down
5 changes: 4 additions & 1 deletion packages/cross_file/lib/src/types/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ abstract class XFileBase {
throw UnimplementedError('.name has not been implemented.');
}

/// For web, it may be necessary for a file to know its MIME type.
/// The MIME type of the file.
///
/// The value is not inferred from the file contents or path. It is only
/// available if provided when the [XFile] was created.
String? get mimeType {
throw UnimplementedError('.mimeType has not been implemented.');
}
Expand Down
6 changes: 6 additions & 0 deletions packages/cross_file/lib/src/types/html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class XFile extends XFileBase {
///
/// `name` needs to be passed from the outside, since it's only available
/// while handling [html.File]s (when the ObjectUrl is created).
///
/// [mimeType] is not inferred from [path] and is only available if explicitly
/// passed to the constructor.
// ignore: use_super_parameters
XFile(
String path, {
Expand All @@ -47,6 +50,9 @@ class XFile extends XFileBase {
}

/// Construct an CrossFile from its data
///
/// [mimeType] is not inferred from [path] and is only available if explicitly
/// passed to the constructor.
XFile.fromData(
Uint8List bytes, {
String? mimeType,
Expand Down
6 changes: 6 additions & 0 deletions packages/cross_file/lib/src/types/io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class XFile extends XFileBase {
/// [length] is ignored; the parameter exists only to match the web version of
/// the constructor.
///
/// [mimeType] is not inferred from [path] and is only available if explicitly
/// passed to the constructor.
///
// ignore: use_super_parameters
XFile(
String path, {
Expand All @@ -40,6 +43,9 @@ class XFile extends XFileBase {

/// Construct an CrossFile from its data
///
/// [mimeType] is not inferred from [path] and is only available if explicitly
/// passed to the constructor.
///
/// [name] is ignored; the parameter exists only to match the web version of
/// the constructor.
XFile.fromData(
Expand Down
2 changes: 1 addition & 1 deletion packages/cross_file/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: cross_file
description: An abstraction to allow working with files across multiple platforms.
repository: https://github.com/flutter/packages/tree/main/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.5+2
version: 0.3.5+3

environment:
sdk: ^3.10.0
Expand Down