Skip to content

[cross_file] Document mime type is not made for io implementations #4549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
4 changes: 3 additions & 1 deletion packages/cross_file/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## NEXT
## 0.3.4+5

* Updates minimum supported SDK version to Flutter 3.3/Dart 2.18.
* Improved documentation about ignored parameters in IO module.=======


## 0.3.3+4

Expand Down
2 changes: 2 additions & 0 deletions packages/cross_file/lib/src/types/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ abstract class XFileBase {
}

/// For web, it may be necessary for a file to know its MIME type.
///
/// For io implementation, this is not intended to be set and will be `null`.
String? get mimeType {
throw UnimplementedError('.mimeType has not been implemented.');
}
Expand Down
21 changes: 21 additions & 0 deletions packages/cross_file/lib/src/types/io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ class XFile extends XFileBase {
/// [bytes] is ignored; the parameter exists only to match the web version of
/// the constructor. To construct a dart:io XFile from bytes, use
/// [XFile.fromData].
///
/// [name] is ignored; the parameter exists only to match the web version of
/// the constructor. **You should avoid using this parameter because it will
/// be likely removed in the future releases.**
///
/// [length] is ignored; the parameter exists only to match the web version of
/// the constructor. **You should avoid using this parameter because it will
/// be likely removed in the future releases.**
///
// ignore: use_super_parameters
XFile(
String path, {
Expand All @@ -32,6 +41,10 @@ class XFile extends XFileBase {
super(path);

/// Construct an CrossFile from its data
///
/// [name] is ignored; the parameter exists only to match the web version of
/// the constructor. **You should avoid using this parameter because it will
/// be likely removed in the future releases.**
XFile.fromData(
Uint8List bytes, {
String? mimeType,
Expand Down Expand Up @@ -82,9 +95,17 @@ class XFile extends XFileBase {
@override
String get path => _file.path;

/// the name extracted from the last part of [File.path].
///
/// **Be aware**, the name here is not the one
/// you may have passed in the constructor/factory.
@override
String get name => _file.path.split(Platform.pathSeparator).last;

/// the [File.length].
///
/// **Be aware**, the length here is not the one
/// you may have passed in the constructor/factory.
@override
Future<int> length() {
if (_length != null) {
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.3+4
version: 0.3.4+5

environment:
sdk: ">=2.18.0 <4.0.0"
Expand Down