Add custom equality and toString
This commit is contained in:
parent
803e47d8db
commit
be454b7cd0
|
@ -1,3 +1,6 @@
|
||||||
|
## 4.0.0+1
|
||||||
|
Overrides equality and toString for `platform_file` and `file_picker_result` for better comparison different results.
|
||||||
|
|
||||||
## 4.0.0
|
## 4.0.0
|
||||||
### Desktop support added for all platforms (MacOS, Linux & Windows) ([#271](https://github.com/miguelpruivo/flutter_file_picker/issues/271)) 🎉
|
### Desktop support added for all platforms (MacOS, Linux & Windows) ([#271](https://github.com/miguelpruivo/flutter_file_picker/issues/271)) 🎉
|
||||||
From now on, you'll be able to use file_picker with all your platforms, a big thanks to @philenius, which made this possible and allowed the [flutter_file_picker_desktop](https://github.com/philenius/flutter_file_picker_desktop) to be merged with this one.
|
From now on, you'll be able to use file_picker with all your platforms, a big thanks to @philenius, which made this possible and allowed the [flutter_file_picker_desktop](https://github.com/philenius/flutter_file_picker_desktop) to be merged with this one.
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// Generated file. Do not edit.
|
// Generated file. Do not edit.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// ignore_for_file: directives_ordering
|
||||||
// ignore_for_file: lines_longer_than_80_chars
|
// ignore_for_file: lines_longer_than_80_chars
|
||||||
|
|
||||||
import 'package:file_picker/src/file_picker_web.dart';
|
import 'package:file_picker/src/file_picker_web.dart';
|
||||||
|
|
|
@ -28,4 +28,17 @@ class FilePickerResult {
|
||||||
|
|
||||||
/// A `List<String>` containing all names from picked files with its extensions.
|
/// A `List<String>` containing all names from picked files with its extensions.
|
||||||
List<String?> get names => files.map((file) => file.name).toList();
|
List<String?> get names => files.map((file) => file.name).toList();
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
if (identical(this, other)) return true;
|
||||||
|
|
||||||
|
return other is FilePickerResult && listEquals(other.files, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => files.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() => 'FilePickerResult(files: $files)';
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,4 +41,30 @@ class PlatformFile {
|
||||||
|
|
||||||
/// File extension for this file.
|
/// File extension for this file.
|
||||||
String? get extension => name.split('.').last;
|
String? get extension => name.split('.').last;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
if (identical(this, other)) return true;
|
||||||
|
|
||||||
|
return other is PlatformFile &&
|
||||||
|
other.path == path &&
|
||||||
|
other.name == name &&
|
||||||
|
other.bytes == bytes &&
|
||||||
|
other.readStream == readStream &&
|
||||||
|
other.size == size;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode {
|
||||||
|
return path.hashCode ^
|
||||||
|
name.hashCode ^
|
||||||
|
bytes.hashCode ^
|
||||||
|
readStream.hashCode ^
|
||||||
|
size.hashCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'PlatformFile(path: $path, name: $name, bytes: $bytes, readStream: $readStream, size: $size)';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ description: A package that allows you to use a native file explorer to pick sin
|
||||||
homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker
|
homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker
|
||||||
repository: https://github.com/miguelpruivo/flutter_file_picker
|
repository: https://github.com/miguelpruivo/flutter_file_picker
|
||||||
issue_tracker: https://github.com/miguelpruivo/flutter_file_picker/issues
|
issue_tracker: https://github.com/miguelpruivo/flutter_file_picker/issues
|
||||||
version: 4.0.0
|
version: 4.0.0+1
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
|
|
Loading…
Reference in New Issue