2020-09-07 19:06:18 +00:00
|
|
|
import 'package:file_picker/src/platform_file.dart';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
|
|
|
|
class FilePickerResult {
|
|
|
|
const FilePickerResult(this.files);
|
|
|
|
|
|
|
|
/// Picked files.
|
|
|
|
final List<PlatformFile> files;
|
|
|
|
|
|
|
|
/// If this pick contains only a single resource.
|
|
|
|
bool get isSinglePick => files.length == 1;
|
|
|
|
|
|
|
|
/// The length of picked files.
|
|
|
|
int get count => files.length;
|
|
|
|
|
|
|
|
/// A `List<String>` containing all paths from picked files.
|
|
|
|
///
|
|
|
|
/// This may or not be available and will typically reference cached copies of
|
|
|
|
/// original files (which can be accessed through its URI property).
|
|
|
|
///
|
|
|
|
/// Only available on IO. Throws `UnsupportedError` on Web.
|
2021-03-03 21:35:49 +00:00
|
|
|
List<String?> get paths => files
|
2021-01-31 17:28:09 +00:00
|
|
|
.map((file) => kIsWeb
|
|
|
|
? throw UnsupportedError(
|
|
|
|
'Picking paths is unsupported on Web. Please, use bytes property instead.')
|
|
|
|
: file.path)
|
2020-09-11 17:37:45 +00:00
|
|
|
.toList();
|
2020-09-07 19:06:18 +00:00
|
|
|
|
|
|
|
/// A `List<String>` containing all names from picked files with its extensions.
|
2020-11-21 21:26:32 +00:00
|
|
|
List<String?> get names => files.map((file) => file.name).toList();
|
2021-08-29 00:57:02 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
bool operator ==(Object other) {
|
2021-08-31 11:02:15 +00:00
|
|
|
if (identical(this, other)) {
|
|
|
|
return true;
|
|
|
|
}
|
2021-08-29 00:57:02 +00:00
|
|
|
|
|
|
|
return other is FilePickerResult && listEquals(other.files, files);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
int get hashCode => files.hashCode;
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() => 'FilePickerResult(files: $files)';
|
2020-09-07 19:06:18 +00:00
|
|
|
}
|