Skip to content

Commit 4d5b3a8

Browse files
Migrate to file_selector (#645)
1 parent cf3857f commit 4d5b3a8

File tree

10 files changed

+83
-46
lines changed

10 files changed

+83
-46
lines changed

experimental/desktop_photo_search/lib/main.dart

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
// found in the LICENSE file.
44

55
import 'dart:io';
6+
import 'dart:typed_data';
67

7-
import 'package:file_chooser/file_chooser.dart' as file_chooser;
8+
import 'package:file_selector/file_selector.dart';
89
import 'package:flutter/foundation.dart';
910
import 'package:flutter/material.dart';
1011
import 'package:flutter_simple_treeview/flutter_simple_treeview.dart';
@@ -101,19 +102,22 @@ class UnsplashHomePage extends StatelessWidget {
101102
? PhotoDetails(
102103
photo: photoSearchModel.selectedPhoto,
103104
onPhotoSave: (photo) async {
104-
final result = await file_chooser.showSavePanel(
105-
suggestedFileName: '${photo.id}.jpg',
106-
allowedFileTypes: const [
107-
file_chooser.FileTypeFilterGroup(
108-
label: 'JPGs',
109-
fileExtensions: ['jpg'],
110-
)
105+
final path = await getSavePath(
106+
suggestedName: '${photo.id}.jpg',
107+
acceptedTypeGroups: <XTypeGroup>[
108+
XTypeGroup(
109+
label: 'JPG',
110+
extensions: ['jpg'],
111+
mimeTypes: ['image/jpeg'],
112+
),
111113
],
112114
);
113-
if (!result.canceled) {
114-
final bytes =
115+
if (path != null) {
116+
final fileData =
115117
await photoSearchModel.download(photo: photo);
116-
await File(result.paths[0]).writeAsBytes(bytes);
118+
final photoFile = XFile.fromData(fileData,
119+
mimeType: 'image/jpeg');
120+
photoFile.saveTo(path);
117121
}
118122
},
119123
)

experimental/desktop_photo_search/linux/flutter/generated_plugin_registrant.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
#include "generated_plugin_registrant.h"
66

7-
#include <file_chooser/file_chooser_plugin.h>
7+
#include <file_selector_linux/file_selector_plugin.h>
88
#include <menubar/menubar_plugin.h>
99
#include <url_launcher_linux/url_launcher_plugin.h>
1010

1111
void fl_register_plugins(FlPluginRegistry* registry) {
12-
g_autoptr(FlPluginRegistrar) file_chooser_registrar =
13-
fl_plugin_registry_get_registrar_for_plugin(registry, "FileChooserPlugin");
14-
file_chooser_plugin_register_with_registrar(file_chooser_registrar);
12+
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
13+
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
14+
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
1515
g_autoptr(FlPluginRegistrar) menubar_registrar =
1616
fl_plugin_registry_get_registrar_for_plugin(registry, "MenubarPlugin");
1717
menubar_plugin_register_with_registrar(menubar_registrar);

experimental/desktop_photo_search/linux/flutter/generated_plugins.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
list(APPEND FLUTTER_PLUGIN_LIST
6-
file_chooser
6+
file_selector_linux
77
menubar
88
url_launcher_linux
99
)

experimental/desktop_photo_search/macos/Flutter/GeneratedPluginRegistrant.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
import FlutterMacOS
66
import Foundation
77

8-
import file_chooser
8+
import file_selector_macos
99
import menubar
1010
import url_launcher_macos
1111

1212
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
13-
FileChooserPlugin.register(with: registry.registrar(forPlugin: "FileChooserPlugin"))
13+
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
1414
MenubarPlugin.register(with: registry.registrar(forPlugin: "MenubarPlugin"))
1515
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
1616
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PODS:
2-
- file_chooser (0.0.2):
2+
- file_selector_macos (0.0.1):
33
- FlutterMacOS
44
- FlutterMacOS (1.0.0)
55
- menubar (0.0.2):
@@ -9,15 +9,15 @@ PODS:
99
- FlutterMacOS
1010

1111
DEPENDENCIES:
12-
- file_chooser (from `Flutter/ephemeral/.symlinks/plugins/file_chooser/macos`)
12+
- file_selector_macos (from `Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos`)
1313
- FlutterMacOS (from `Flutter/ephemeral/.symlinks/flutter/darwin-x64`)
1414
- menubar (from `Flutter/ephemeral/.symlinks/plugins/menubar/macos`)
1515
- url_launcher (from `Flutter/ephemeral/.symlinks/plugins/url_launcher/macos`)
1616
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
1717

1818
EXTERNAL SOURCES:
19-
file_chooser:
20-
:path: Flutter/ephemeral/.symlinks/plugins/file_chooser/macos
19+
file_selector_macos:
20+
:path: Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos
2121
FlutterMacOS:
2222
:path: Flutter/ephemeral/.symlinks/flutter/darwin-x64
2323
menubar:
@@ -28,12 +28,12 @@ EXTERNAL SOURCES:
2828
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
2929

3030
SPEC CHECKSUMS:
31-
file_chooser: 24432cf5dc836722b05c11c2a0a30d19c3c9b996
31+
file_selector_macos: ff6dc948d4ddd34e8602a1f60b7d0b4cc6051a47
3232
FlutterMacOS: 15bea8a44d2fa024068daa0140371c020b4b6ff9
3333
menubar: 4e3d461d62d775540277ce6639acafe2a111a231
3434
url_launcher: af78307ef9bafff91273b34f1c6c0c86a0004fd7
3535
url_launcher_macos: 45af3d61de06997666568a7149c1be98b41c95d4
3636

3737
PODFILE CHECKSUM: d8ba9b3e9e93c62c74a660b46c6fcb09f03991a7
3838

39-
COCOAPODS: 1.9.3
39+
COCOAPODS: 1.10.0

experimental/desktop_photo_search/macos/Runner.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,10 @@
307307
buildActionMask = 2147483647;
308308
files = (
309309
);
310-
inputFileListPaths = (
310+
inputPaths = (
311311
);
312312
name = "[CP] Embed Pods Frameworks";
313-
outputFileListPaths = (
313+
outputPaths = (
314314
);
315315
runOnlyForDeploymentPostprocessing = 0;
316316
shellPath = /bin/sh;

experimental/desktop_photo_search/pubspec.lock

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ packages:
7070
name: build_daemon
7171
url: "https://pub.dartlang.org"
7272
source: hosted
73-
version: "2.1.4"
73+
version: "2.1.5"
7474
build_resolvers:
7575
dependency: transitive
7676
description:
@@ -176,6 +176,13 @@ packages:
176176
url: "https://pub.dartlang.org"
177177
source: hosted
178178
version: "0.14.2"
179+
cross_file:
180+
dependency: transitive
181+
description:
182+
name: cross_file
183+
url: "https://pub.dartlang.org"
184+
source: hosted
185+
version: "0.1.0"
179186
crypto:
180187
dependency: transitive
181188
description:
@@ -218,15 +225,41 @@ packages:
218225
url: "https://pub.dartlang.org"
219226
source: hosted
220227
version: "5.2.1"
221-
file_chooser:
228+
file_selector:
222229
dependency: "direct main"
223230
description:
224-
path: "plugins/file_chooser"
225-
ref: HEAD
226-
resolved-ref: "040f36c82b63e8764ec2fd97066767503a667b6d"
227-
url: "https://github.com/google/flutter-desktop-embedding.git"
228-
source: git
229-
version: "0.2.0"
231+
name: file_selector
232+
url: "https://pub.dartlang.org"
233+
source: hosted
234+
version: "0.7.0+2"
235+
file_selector_linux:
236+
dependency: "direct main"
237+
description:
238+
name: file_selector_linux
239+
url: "https://pub.dartlang.org"
240+
source: hosted
241+
version: "0.0.1"
242+
file_selector_macos:
243+
dependency: "direct main"
244+
description:
245+
name: file_selector_macos
246+
url: "https://pub.dartlang.org"
247+
source: hosted
248+
version: "0.0.1"
249+
file_selector_platform_interface:
250+
dependency: transitive
251+
description:
252+
name: file_selector_platform_interface
253+
url: "https://pub.dartlang.org"
254+
source: hosted
255+
version: "1.0.2"
256+
file_selector_windows:
257+
dependency: "direct main"
258+
description:
259+
name: file_selector_windows
260+
url: "https://pub.dartlang.org"
261+
source: hosted
262+
version: "0.0.1"
230263
fixnum:
231264
dependency: transitive
232265
description:
@@ -352,7 +385,7 @@ packages:
352385
description:
353386
path: "plugins/menubar"
354387
ref: HEAD
355-
resolved-ref: "040f36c82b63e8764ec2fd97066767503a667b6d"
388+
resolved-ref: ff9c2aebbbf673f9726f5c8052f6a21099fa51fd
356389
url: "https://github.com/google/flutter-desktop-embedding.git"
357390
source: git
358391
version: "0.1.0"
@@ -376,7 +409,7 @@ packages:
376409
name: msix
377410
url: "https://pub.dartlang.org"
378411
source: hosted
379-
version: "0.1.7"
412+
version: "0.1.10"
380413
nested:
381414
dependency: transitive
382415
description:

experimental/desktop_photo_search/pubspec.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ dependencies:
1313
built_collection: ^4.3.0
1414
built_value: ^7.0.0
1515
cupertino_icons: ^0.1.3
16-
file_chooser:
17-
git:
18-
url: https://github.com/google/flutter-desktop-embedding.git
19-
path: plugins/file_chooser
16+
file_selector: ^0.7.0
17+
file_selector_linux: ^0.0.1
18+
file_selector_macos: ^0.0.1
19+
file_selector_windows: ^0.0.1
2020
http: ^0.12.2
2121
logging: ^0.11.3+2
2222
flutter_simple_treeview: ^2.0.1
@@ -53,7 +53,7 @@ msix_config:
5353
publisher: CN=01A6D5C0-D51A-4EEE-8DD0-F134DDD378F7
5454
identity_name: 16354flutter.dev.FlutterDesktopPhotoSearch
5555
msix_version: 1.0.0.0
56-
icons_background_color: '#ffffff'
56+
icons_background_color: "#ffffff"
5757
architecture: x64
5858
# See https://docs.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations
59-
capabilities: 'internetClient'
59+
capabilities: "internetClient"

experimental/desktop_photo_search/windows/flutter/generated_plugin_registrant.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
#include "generated_plugin_registrant.h"
66

7-
#include <file_chooser/file_chooser_plugin.h>
7+
#include <file_selector_windows/file_selector_plugin.h>
88
#include <menubar/menubar_plugin.h>
99
#include <url_launcher_windows/url_launcher_plugin.h>
1010

1111
void RegisterPlugins(flutter::PluginRegistry* registry) {
12-
FileChooserPluginRegisterWithRegistrar(
13-
registry->GetRegistrarForPlugin("FileChooserPlugin"));
12+
FileSelectorPluginRegisterWithRegistrar(
13+
registry->GetRegistrarForPlugin("FileSelectorPlugin"));
1414
MenubarPluginRegisterWithRegistrar(
1515
registry->GetRegistrarForPlugin("MenubarPlugin"));
1616
UrlLauncherPluginRegisterWithRegistrar(

experimental/desktop_photo_search/windows/flutter/generated_plugins.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
list(APPEND FLUTTER_PLUGIN_LIST
6-
file_chooser
6+
file_selector_windows
77
menubar
88
url_launcher_windows
99
)

0 commit comments

Comments
 (0)