From 86dbe35474f036e88e2f2ceca56df92e346447ce Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Sat, 21 Jun 2025 20:50:47 +0900 Subject: [PATCH 1/3] feat: support xdp selector for linux just a patch ready now.. no need to do pr --- lib/utils/file_selector.dart | 34 ++++++------------- .../matrix_file_extension.dart | 6 ++-- pubspec.lock | 11 +++--- pubspec.yaml | 5 ++- 4 files changed, 22 insertions(+), 34 deletions(-) diff --git a/lib/utils/file_selector.dart b/lib/utils/file_selector.dart index fd35891af9..2e09b492f3 100644 --- a/lib/utils/file_selector.dart +++ b/lib/utils/file_selector.dart @@ -3,7 +3,6 @@ import 'package:flutter/widgets.dart'; import 'package:file_picker/file_picker.dart'; import 'package:file_selector/file_selector.dart'; -import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/widgets/app_lock.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; @@ -13,31 +12,18 @@ Future> selectFiles( FileSelectorType type = FileSelectorType.any, bool allowMultiple = false, }) async { - if (!PlatformInfos.isLinux) { - final result = await AppLock.of(context).pauseWhile( - showFutureLoadingDialog( - context: context, - future: () => FilePicker.platform.pickFiles( - compressionQuality: 0, - allowMultiple: allowMultiple, - type: type.filePickerType, - allowedExtensions: type.extensions, - ), + final result = await AppLock.of(context).pauseWhile( + showFutureLoadingDialog( + context: context, + future: () => FilePicker.platform.pickFiles( + compressionQuality: 0, + allowMultiple: allowMultiple, + type: type.filePickerType, + allowedExtensions: type.extensions, ), - ); - return result.result?.xFiles ?? []; - } - - if (allowMultiple) { - return await AppLock.of(context).pauseWhile( - openFiles(confirmButtonText: title, acceptedTypeGroups: type.groups), - ); - } - final file = await AppLock.of(context).pauseWhile( - openFile(confirmButtonText: title, acceptedTypeGroups: type.groups), + ), ); - if (file == null) return []; - return [file]; + return result.result?.xFiles ?? []; } enum FileSelectorType { diff --git a/lib/utils/matrix_sdk_extensions/matrix_file_extension.dart b/lib/utils/matrix_sdk_extensions/matrix_file_extension.dart index 01b2d85e41..4400f6af57 100644 --- a/lib/utils/matrix_sdk_extensions/matrix_file_extension.dart +++ b/lib/utils/matrix_sdk_extensions/matrix_file_extension.dart @@ -3,7 +3,6 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:file_picker/file_picker.dart'; -import 'package:file_selector/file_selector.dart'; import 'package:matrix/matrix.dart'; import 'package:share_plus/share_plus.dart'; import 'package:universal_html/html.dart' as html; @@ -21,11 +20,10 @@ extension MatrixFileExtension on MatrixFile { } final downloadPath = !PlatformInfos.isMobile - ? (await getSaveLocation( - suggestedName: name, + ? (await FilePicker.platform.saveFile( + fileName: name, confirmButtonText: L10n.of(context).saveFile, )) - ?.path : await FilePicker.platform.saveFile( dialogTitle: L10n.of(context).saveFile, fileName: name, diff --git a/pubspec.lock b/pubspec.lock index 3567b97bb2..cff932aba5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -393,11 +393,12 @@ packages: file_picker: dependency: "direct main" description: - name: file_picker - sha256: ab13ae8ef5580a411c458d6207b6774a6c237d77ac37011b13994879f68a8810 - url: "https://pub.dev" - source: hosted - version: "8.3.7" + path: "." + ref: xdppicker + resolved-ref: e7ae7cebc5ba4ffbfeedb190859a0f443bb0f079 + url: "https://github.com/Decodetalkers/flutter_file_picker" + source: git + version: "10.2.0" file_selector: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index ee092c7b6d..60936e647d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -25,7 +25,10 @@ dependencies: emoji_picker_flutter: ^3.1.0 emojis: ^0.9.9 #fcm_shared_isolate: ^0.2.0 - file_picker: ^8.1.2 + file_picker: + git: + url: https://github.com/Decodetalkers/flutter_file_picker + ref: xdppicker file_selector: ^1.0.3 flutter: sdk: flutter From 93ca5a7ec85316a865b02c503ca2e45e7036f754 Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Sun, 22 Jun 2025 23:31:08 +0900 Subject: [PATCH 2/3] chore: update fork with new commit --- pubspec.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.lock b/pubspec.lock index cff932aba5..8953a7689a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -395,7 +395,7 @@ packages: description: path: "." ref: xdppicker - resolved-ref: e7ae7cebc5ba4ffbfeedb190859a0f443bb0f079 + resolved-ref: "9be4a01935a27d426a6c43407a5dbbea44e12085" url: "https://github.com/Decodetalkers/flutter_file_picker" source: git version: "10.2.0" From f5cf59bb643c3b44c1f46c276888444b87d56f4f Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Sun, 22 Jun 2025 23:34:19 +0900 Subject: [PATCH 3/3] chore: remove useless code --- .../matrix_file_extension.dart | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/utils/matrix_sdk_extensions/matrix_file_extension.dart b/lib/utils/matrix_sdk_extensions/matrix_file_extension.dart index 4400f6af57..8b3738462c 100644 --- a/lib/utils/matrix_sdk_extensions/matrix_file_extension.dart +++ b/lib/utils/matrix_sdk_extensions/matrix_file_extension.dart @@ -19,17 +19,12 @@ extension MatrixFileExtension on MatrixFile { return; } - final downloadPath = !PlatformInfos.isMobile - ? (await FilePicker.platform.saveFile( - fileName: name, - confirmButtonText: L10n.of(context).saveFile, - )) - : await FilePicker.platform.saveFile( - dialogTitle: L10n.of(context).saveFile, - fileName: name, - type: filePickerFileType, - bytes: bytes, - ); + final downloadPath = await FilePicker.platform.saveFile( + dialogTitle: L10n.of(context).saveFile, + fileName: name, + type: filePickerFileType, + bytes: bytes, + ); if (downloadPath == null) return; if (PlatformInfos.isDesktop) {