Skip to content

Commit 1a79271

Browse files
committed
Clarify cross_file MIME type docs
1 parent 70ff7f8 commit 1a79271

5 files changed

Lines changed: 19 additions & 1 deletion

File tree

packages/cross_file/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## NEXT
22

3+
* Clarifies that `XFile.mimeType` is not inferred from the file path or contents.
34
* Updates minimum supported SDK version to Flutter 3.35/Dart 3.9.
45

56
## 0.3.5+2

packages/cross_file/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ final String fileContent = await file.readAsString();
2323
print('Content of the file: $fileContent');
2424
```
2525

26+
The `mimeType` property is not inferred from the file path or contents. It is
27+
only available if provided when the `XFile` was created, or if available from the
28+
platform-backed file.
29+
2630
You will find links to the API docs on the [pub page](https://pub.dev/packages/cross_file).
2731

2832
## Web Limitations

packages/cross_file/lib/src/types/base.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ abstract class XFileBase {
4545
throw UnimplementedError('.name has not been implemented.');
4646
}
4747

48-
/// For web, it may be necessary for a file to know its MIME type.
48+
/// The MIME type of the file.
49+
///
50+
/// The value is not inferred from the file contents or path. It is only
51+
/// available if provided when the [XFile] was created, or if available from
52+
/// the platform-backed file.
4953
String? get mimeType {
5054
throw UnimplementedError('.mimeType has not been implemented.');
5155
}

packages/cross_file/lib/src/types/html.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class XFile extends XFileBase {
2626
///
2727
/// `name` needs to be passed from the outside, since it's only available
2828
/// while handling [html.File]s (when the ObjectUrl is created).
29+
///
30+
/// [mimeType] is only available if explicitly passed to the constructor.
2931
// ignore: use_super_parameters
3032
XFile(
3133
String path, {
@@ -47,6 +49,8 @@ class XFile extends XFileBase {
4749
}
4850

4951
/// Construct an CrossFile from its data
52+
///
53+
/// [mimeType] is only available if explicitly passed to the constructor.
5054
XFile.fromData(
5155
Uint8List bytes, {
5256
String? mimeType,

packages/cross_file/lib/src/types/io.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ class XFile extends XFileBase {
2424
/// [length] is ignored; the parameter exists only to match the web version of
2525
/// the constructor.
2626
///
27+
/// [mimeType] is not inferred from [path] and is only available if explicitly
28+
/// passed to the constructor.
29+
///
2730
// ignore: use_super_parameters
2831
XFile(
2932
String path, {
@@ -40,6 +43,8 @@ class XFile extends XFileBase {
4043

4144
/// Construct an CrossFile from its data
4245
///
46+
/// [mimeType] is only available if explicitly passed to the constructor.
47+
///
4348
/// [name] is ignored; the parameter exists only to match the web version of
4449
/// the constructor.
4550
XFile.fromData(

0 commit comments

Comments
 (0)