Migrate to file_selector (#645)

pull/661/head
Brett Morgan 5 years ago committed by GitHub
parent cf3857f271
commit 4d5b3a863e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,8 +3,9 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io'; import 'dart:io';
import 'dart:typed_data';
import 'package:file_chooser/file_chooser.dart' as file_chooser; import 'package:file_selector/file_selector.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_simple_treeview/flutter_simple_treeview.dart'; import 'package:flutter_simple_treeview/flutter_simple_treeview.dart';
@ -101,19 +102,22 @@ class UnsplashHomePage extends StatelessWidget {
? PhotoDetails( ? PhotoDetails(
photo: photoSearchModel.selectedPhoto, photo: photoSearchModel.selectedPhoto,
onPhotoSave: (photo) async { onPhotoSave: (photo) async {
final result = await file_chooser.showSavePanel( final path = await getSavePath(
suggestedFileName: '${photo.id}.jpg', suggestedName: '${photo.id}.jpg',
allowedFileTypes: const [ acceptedTypeGroups: <XTypeGroup>[
file_chooser.FileTypeFilterGroup( XTypeGroup(
label: 'JPGs', label: 'JPG',
fileExtensions: ['jpg'], extensions: ['jpg'],
) mimeTypes: ['image/jpeg'],
),
], ],
); );
if (!result.canceled) { if (path != null) {
final bytes = final fileData =
await photoSearchModel.download(photo: photo); await photoSearchModel.download(photo: photo);
await File(result.paths[0]).writeAsBytes(bytes); final photoFile = XFile.fromData(fileData,
mimeType: 'image/jpeg');
photoFile.saveTo(path);
} }
}, },
) )

@ -4,14 +4,14 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <file_chooser/file_chooser_plugin.h> #include <file_selector_linux/file_selector_plugin.h>
#include <menubar/menubar_plugin.h> #include <menubar/menubar_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h> #include <url_launcher_linux/url_launcher_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) { void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) file_chooser_registrar = g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileChooserPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
file_chooser_plugin_register_with_registrar(file_chooser_registrar); file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
g_autoptr(FlPluginRegistrar) menubar_registrar = g_autoptr(FlPluginRegistrar) menubar_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "MenubarPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "MenubarPlugin");
menubar_plugin_register_with_registrar(menubar_registrar); menubar_plugin_register_with_registrar(menubar_registrar);

@ -3,7 +3,7 @@
# #
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
file_chooser file_selector_linux
menubar menubar
url_launcher_linux url_launcher_linux
) )

@ -5,12 +5,12 @@
import FlutterMacOS import FlutterMacOS
import Foundation import Foundation
import file_chooser import file_selector_macos
import menubar import menubar
import url_launcher_macos import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FileChooserPlugin.register(with: registry.registrar(forPlugin: "FileChooserPlugin")) FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
MenubarPlugin.register(with: registry.registrar(forPlugin: "MenubarPlugin")) MenubarPlugin.register(with: registry.registrar(forPlugin: "MenubarPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
} }

@ -1,5 +1,5 @@
PODS: PODS:
- file_chooser (0.0.2): - file_selector_macos (0.0.1):
- FlutterMacOS - FlutterMacOS
- FlutterMacOS (1.0.0) - FlutterMacOS (1.0.0)
- menubar (0.0.2): - menubar (0.0.2):
@ -9,15 +9,15 @@ PODS:
- FlutterMacOS - FlutterMacOS
DEPENDENCIES: DEPENDENCIES:
- file_chooser (from `Flutter/ephemeral/.symlinks/plugins/file_chooser/macos`) - file_selector_macos (from `Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos`)
- FlutterMacOS (from `Flutter/ephemeral/.symlinks/flutter/darwin-x64`) - FlutterMacOS (from `Flutter/ephemeral/.symlinks/flutter/darwin-x64`)
- menubar (from `Flutter/ephemeral/.symlinks/plugins/menubar/macos`) - menubar (from `Flutter/ephemeral/.symlinks/plugins/menubar/macos`)
- url_launcher (from `Flutter/ephemeral/.symlinks/plugins/url_launcher/macos`) - url_launcher (from `Flutter/ephemeral/.symlinks/plugins/url_launcher/macos`)
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
EXTERNAL SOURCES: EXTERNAL SOURCES:
file_chooser: file_selector_macos:
:path: Flutter/ephemeral/.symlinks/plugins/file_chooser/macos :path: Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos
FlutterMacOS: FlutterMacOS:
:path: Flutter/ephemeral/.symlinks/flutter/darwin-x64 :path: Flutter/ephemeral/.symlinks/flutter/darwin-x64
menubar: menubar:
@ -28,7 +28,7 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
SPEC CHECKSUMS: SPEC CHECKSUMS:
file_chooser: 24432cf5dc836722b05c11c2a0a30d19c3c9b996 file_selector_macos: ff6dc948d4ddd34e8602a1f60b7d0b4cc6051a47
FlutterMacOS: 15bea8a44d2fa024068daa0140371c020b4b6ff9 FlutterMacOS: 15bea8a44d2fa024068daa0140371c020b4b6ff9
menubar: 4e3d461d62d775540277ce6639acafe2a111a231 menubar: 4e3d461d62d775540277ce6639acafe2a111a231
url_launcher: af78307ef9bafff91273b34f1c6c0c86a0004fd7 url_launcher: af78307ef9bafff91273b34f1c6c0c86a0004fd7
@ -36,4 +36,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: d8ba9b3e9e93c62c74a660b46c6fcb09f03991a7 PODFILE CHECKSUM: d8ba9b3e9e93c62c74a660b46c6fcb09f03991a7
COCOAPODS: 1.9.3 COCOAPODS: 1.10.0

@ -307,10 +307,10 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
); );
inputFileListPaths = ( inputPaths = (
); );
name = "[CP] Embed Pods Frameworks"; name = "[CP] Embed Pods Frameworks";
outputFileListPaths = ( outputPaths = (
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;

@ -70,7 +70,7 @@ packages:
name: build_daemon name: build_daemon
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.4" version: "2.1.5"
build_resolvers: build_resolvers:
dependency: transitive dependency: transitive
description: description:
@ -176,6 +176,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.14.2" version: "0.14.2"
cross_file:
dependency: transitive
description:
name: cross_file
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
crypto: crypto:
dependency: transitive dependency: transitive
description: description:
@ -218,15 +225,41 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "5.2.1" version: "5.2.1"
file_chooser: file_selector:
dependency: "direct main" dependency: "direct main"
description: description:
path: "plugins/file_chooser" name: file_selector
ref: HEAD url: "https://pub.dartlang.org"
resolved-ref: "040f36c82b63e8764ec2fd97066767503a667b6d" source: hosted
url: "https://github.com/google/flutter-desktop-embedding.git" version: "0.7.0+2"
source: git file_selector_linux:
version: "0.2.0" dependency: "direct main"
description:
name: file_selector_linux
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1"
file_selector_macos:
dependency: "direct main"
description:
name: file_selector_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1"
file_selector_platform_interface:
dependency: transitive
description:
name: file_selector_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
file_selector_windows:
dependency: "direct main"
description:
name: file_selector_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1"
fixnum: fixnum:
dependency: transitive dependency: transitive
description: description:
@ -352,7 +385,7 @@ packages:
description: description:
path: "plugins/menubar" path: "plugins/menubar"
ref: HEAD ref: HEAD
resolved-ref: "040f36c82b63e8764ec2fd97066767503a667b6d" resolved-ref: ff9c2aebbbf673f9726f5c8052f6a21099fa51fd
url: "https://github.com/google/flutter-desktop-embedding.git" url: "https://github.com/google/flutter-desktop-embedding.git"
source: git source: git
version: "0.1.0" version: "0.1.0"
@ -376,7 +409,7 @@ packages:
name: msix name: msix
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.7" version: "0.1.10"
nested: nested:
dependency: transitive dependency: transitive
description: description:

@ -13,10 +13,10 @@ dependencies:
built_collection: ^4.3.0 built_collection: ^4.3.0
built_value: ^7.0.0 built_value: ^7.0.0
cupertino_icons: ^0.1.3 cupertino_icons: ^0.1.3
file_chooser: file_selector: ^0.7.0
git: file_selector_linux: ^0.0.1
url: https://github.com/google/flutter-desktop-embedding.git file_selector_macos: ^0.0.1
path: plugins/file_chooser file_selector_windows: ^0.0.1
http: ^0.12.2 http: ^0.12.2
logging: ^0.11.3+2 logging: ^0.11.3+2
flutter_simple_treeview: ^2.0.1 flutter_simple_treeview: ^2.0.1
@ -53,7 +53,7 @@ msix_config:
publisher: CN=01A6D5C0-D51A-4EEE-8DD0-F134DDD378F7 publisher: CN=01A6D5C0-D51A-4EEE-8DD0-F134DDD378F7
identity_name: 16354flutter.dev.FlutterDesktopPhotoSearch identity_name: 16354flutter.dev.FlutterDesktopPhotoSearch
msix_version: 1.0.0.0 msix_version: 1.0.0.0
icons_background_color: '#ffffff' icons_background_color: "#ffffff"
architecture: x64 architecture: x64
# See https://docs.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations # See https://docs.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations
capabilities: 'internetClient' capabilities: "internetClient"

@ -4,13 +4,13 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <file_chooser/file_chooser_plugin.h> #include <file_selector_windows/file_selector_plugin.h>
#include <menubar/menubar_plugin.h> #include <menubar/menubar_plugin.h>
#include <url_launcher_windows/url_launcher_plugin.h> #include <url_launcher_windows/url_launcher_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) { void RegisterPlugins(flutter::PluginRegistry* registry) {
FileChooserPluginRegisterWithRegistrar( FileSelectorPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileChooserPlugin")); registry->GetRegistrarForPlugin("FileSelectorPlugin"));
MenubarPluginRegisterWithRegistrar( MenubarPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("MenubarPlugin")); registry->GetRegistrarForPlugin("MenubarPlugin"));
UrlLauncherPluginRegisterWithRegistrar( UrlLauncherPluginRegisterWithRegistrar(

@ -3,7 +3,7 @@
# #
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
file_chooser file_selector_windows
menubar menubar
url_launcher_windows url_launcher_windows
) )

Loading…
Cancel
Save