Fix custom filter String creation

This commit is contained in:
Miguel Ruivo 2020-08-05 10:07:17 +01:00
parent 3d12c5ece8
commit 506cf55516
3 changed files with 11 additions and 14 deletions

View File

@ -1,3 +1,7 @@
## 1.0.2+1
Fix custom filter String creation.
## 1.0.2
Addresses an issue that would cause dot being required on filters for web (#343)

View File

@ -17,10 +17,8 @@ class FilePicker extends FilePickerPlatform {
/// [allowedExtensions] can be used (eg. `[.jpg, .pdf]`) to restrict picking types
///
/// Returns a `List<html.File>`
static Future<List<html.File>> getMultiFile(
{FileType type = FileType.any, List<String> allowedExtensions}) async {
return await _instance.getFiles(
type: type, allowMultiple: true, allowedExtensions: allowedExtensions);
static Future<List<html.File>> getMultiFile({FileType type = FileType.any, List<String> allowedExtensions}) async {
return await _instance.getFiles(type: type, allowMultiple: true, allowedExtensions: allowedExtensions);
}
/// Opens browser file picker window to select a single file.
@ -28,11 +26,8 @@ class FilePicker extends FilePickerPlatform {
/// [allowedExtensions] can be used (eg. `[.jpg, .pdf]`) to restrict picking types
///
/// Returns a `html.File`
static Future<html.File> getFile(
{FileType type = FileType.any, List<String> allowedExtensions}) async {
return (await _instance.getFiles(
type: type, allowedExtensions: allowedExtensions))
.first;
static Future<html.File> getFile({FileType type = FileType.any, List<String> allowedExtensions}) async {
return (await _instance.getFiles(type: type, allowedExtensions: allowedExtensions)).first;
}
@override
@ -46,8 +41,7 @@ class FilePicker extends FilePickerPlatform {
html.InputElement uploadInput = html.FileUploadInputElement();
uploadInput.multiple = allowMultiple;
uploadInput.accept = _fileType(type, allowedExtensions);
uploadInput.onChange
.listen((event) => pickedFiles.complete(uploadInput.files));
uploadInput.onChange.listen((event) => pickedFiles.complete(uploadInput.files));
uploadInput.click();
return await pickedFiles.future;
}
@ -70,8 +64,7 @@ class FilePicker extends FilePickerPlatform {
return 'video/*|image/*';
case FileType.custom:
return allowedExtensions
.reduce((value, element) => '.$value,.$element');
return allowedExtensions.fold('', (prev, next) => '${prev.isEmpty ? '' : '$prev,'} .$next');
break;
}
return '';

View File

@ -1,7 +1,7 @@
name: file_picker_web
description: Web platform implementation of file_picker. Provides a way to pick files with filter support for Web.
homepage: https://github.com/miguelpruivo/flutter_file_picker/tree/master/file_picker_web
version: 1.0.2
version: 1.0.2+1
environment:
sdk: ">=2.7.0 <3.0.0"