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.
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/material.dart';
import 'package:flutter_simple_treeview/flutter_simple_treeview.dart';
@ -101,19 +102,22 @@ class UnsplashHomePage extends StatelessWidget {
? PhotoDetails(
photo: photoSearchModel.selectedPhoto,
onPhotoSave: (photo) async {
final result = await file_chooser.showSavePanel(
suggestedFileName: '${photo.id}.jpg',
allowedFileTypes: const [
file_chooser.FileTypeFilterGroup(
label: 'JPGs',
fileExtensions: ['jpg'],
)
final path = await getSavePath(
suggestedName: '${photo.id}.jpg',
acceptedTypeGroups: <XTypeGroup>[
XTypeGroup(
label: 'JPG',
extensions: ['jpg'],
mimeTypes: ['image/jpeg'],
),
],
);
if (!result.canceled) {
final bytes =
if (path != null) {
final fileData =
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 <file_chooser/file_chooser_plugin.h>
#include <file_selector_linux/file_selector_plugin.h>
#include <menubar/menubar_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) file_chooser_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileChooserPlugin");
file_chooser_plugin_register_with_registrar(file_chooser_registrar);
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
g_autoptr(FlPluginRegistrar) menubar_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "MenubarPlugin");
menubar_plugin_register_with_registrar(menubar_registrar);

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

@ -5,12 +5,12 @@
import FlutterMacOS
import Foundation
import file_chooser
import file_selector_macos
import menubar
import url_launcher_macos
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"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}

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

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

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

@ -13,10 +13,10 @@ dependencies:
built_collection: ^4.3.0
built_value: ^7.0.0
cupertino_icons: ^0.1.3
file_chooser:
git:
url: https://github.com/google/flutter-desktop-embedding.git
path: plugins/file_chooser
file_selector: ^0.7.0
file_selector_linux: ^0.0.1
file_selector_macos: ^0.0.1
file_selector_windows: ^0.0.1
http: ^0.12.2
logging: ^0.11.3+2
flutter_simple_treeview: ^2.0.1
@ -53,7 +53,7 @@ msix_config:
publisher: CN=01A6D5C0-D51A-4EEE-8DD0-F134DDD378F7
identity_name: 16354flutter.dev.FlutterDesktopPhotoSearch
msix_version: 1.0.0.0
icons_background_color: '#ffffff'
icons_background_color: "#ffffff"
architecture: x64
# 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 <file_chooser/file_chooser_plugin.h>
#include <file_selector_windows/file_selector_plugin.h>
#include <menubar/menubar_plugin.h>
#include <url_launcher_windows/url_launcher_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
FileChooserPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileChooserPlugin"));
FileSelectorPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSelectorPlugin"));
MenubarPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("MenubarPlugin"));
UrlLauncherPluginRegisterWithRegistrar(

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

Loading…
Cancel
Save