Update file_selector_* to the latest pigeon (#3562)
Update file_selector_* to the latest pigeon
diff --git a/packages/file_selector/file_selector_ios/CHANGELOG.md b/packages/file_selector/file_selector_ios/CHANGELOG.md
index f79cb92..1404a74 100644
--- a/packages/file_selector/file_selector_ios/CHANGELOG.md
+++ b/packages/file_selector/file_selector_ios/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.5.1+2
+
+* Updates to `pigeon` version 9.
+
## 0.5.1+1
* Clarifies explanation of endorsement in README.
diff --git a/packages/file_selector/file_selector_ios/ios/Classes/messages.g.h b/packages/file_selector/file_selector_ios/ios/Classes/messages.g.h
index a04b411..bcca1d9 100644
--- a/packages/file_selector/file_selector_ios/ios/Classes/messages.g.h
+++ b/packages/file_selector/file_selector_ios/ios/Classes/messages.g.h
@@ -1,9 +1,11 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Autogenerated from Pigeon (v3.2.5), do not edit directly.
+// Autogenerated from Pigeon (v9.1.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon
+
#import <Foundation/Foundation.h>
+
@protocol FlutterBinaryMessenger;
@protocol FlutterMessageCodec;
@class FlutterError;
diff --git a/packages/file_selector/file_selector_ios/ios/Classes/messages.g.m b/packages/file_selector/file_selector_ios/ios/Classes/messages.g.m
index d4046d2..9d31772 100644
--- a/packages/file_selector/file_selector_ios/ios/Classes/messages.g.m
+++ b/packages/file_selector/file_selector_ios/ios/Classes/messages.g.m
@@ -1,8 +1,9 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Autogenerated from Pigeon (v3.2.5), do not edit directly.
+// Autogenerated from Pigeon (v9.1.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon
+
#import "messages.g.h"
#import <Flutter/Flutter.h>
@@ -10,23 +11,13 @@
#error File requires ARC to be enabled.
#endif
-static NSDictionary<NSString *, id> *wrapResult(id result, FlutterError *error) {
- NSDictionary *errorDict = (NSDictionary *)[NSNull null];
+static NSArray *wrapResult(id result, FlutterError *error) {
if (error) {
- errorDict = @{
- @"code" : (error.code ?: [NSNull null]),
- @"message" : (error.message ?: [NSNull null]),
- @"details" : (error.details ?: [NSNull null]),
- };
+ return @[
+ error.code ?: [NSNull null], error.message ?: [NSNull null], error.details ?: [NSNull null]
+ ];
}
- return @{
- @"result" : (result ?: [NSNull null]),
- @"error" : errorDict,
- };
-}
-static id GetNullableObject(NSDictionary *dict, id key) {
- id result = dict[key];
- return (result == [NSNull null]) ? nil : result;
+ return @[ result ?: [NSNull null] ];
}
static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
id result = array[key];
@@ -34,9 +25,9 @@
}
@interface FFSFileSelectorConfig ()
-+ (FFSFileSelectorConfig *)fromMap:(NSDictionary *)dict;
-+ (nullable FFSFileSelectorConfig *)nullableFromMap:(NSDictionary *)dict;
-- (NSDictionary *)toMap;
++ (FFSFileSelectorConfig *)fromList:(NSArray *)list;
++ (nullable FFSFileSelectorConfig *)nullableFromList:(NSArray *)list;
+- (NSArray *)toList;
@end
@implementation FFSFileSelectorConfig
@@ -47,22 +38,22 @@
pigeonResult.allowMultiSelection = allowMultiSelection;
return pigeonResult;
}
-+ (FFSFileSelectorConfig *)fromMap:(NSDictionary *)dict {
++ (FFSFileSelectorConfig *)fromList:(NSArray *)list {
FFSFileSelectorConfig *pigeonResult = [[FFSFileSelectorConfig alloc] init];
- pigeonResult.utis = GetNullableObject(dict, @"utis");
+ pigeonResult.utis = GetNullableObjectAtIndex(list, 0);
NSAssert(pigeonResult.utis != nil, @"");
- pigeonResult.allowMultiSelection = GetNullableObject(dict, @"allowMultiSelection");
+ pigeonResult.allowMultiSelection = GetNullableObjectAtIndex(list, 1);
NSAssert(pigeonResult.allowMultiSelection != nil, @"");
return pigeonResult;
}
-+ (nullable FFSFileSelectorConfig *)nullableFromMap:(NSDictionary *)dict {
- return (dict) ? [FFSFileSelectorConfig fromMap:dict] : nil;
++ (nullable FFSFileSelectorConfig *)nullableFromList:(NSArray *)list {
+ return (list) ? [FFSFileSelectorConfig fromList:list] : nil;
}
-- (NSDictionary *)toMap {
- return @{
- @"utis" : (self.utis ?: [NSNull null]),
- @"allowMultiSelection" : (self.allowMultiSelection ?: [NSNull null]),
- };
+- (NSArray *)toList {
+ return @[
+ (self.utis ?: [NSNull null]),
+ (self.allowMultiSelection ?: [NSNull null]),
+ ];
}
@end
@@ -72,8 +63,7 @@
- (nullable id)readValueOfType:(UInt8)type {
switch (type) {
case 128:
- return [FFSFileSelectorConfig fromMap:[self readValue]];
-
+ return [FFSFileSelectorConfig fromList:[self readValue]];
default:
return [super readValueOfType:type];
}
@@ -86,7 +76,7 @@
- (void)writeValue:(id)value {
if ([value isKindOfClass:[FFSFileSelectorConfig class]]) {
[self writeByte:128];
- [self writeValue:[value toMap]];
+ [self writeValue:[value toList]];
} else {
[super writeValue:value];
}
@@ -105,8 +95,8 @@
@end
NSObject<FlutterMessageCodec> *FFSFileSelectorApiGetCodec() {
- static dispatch_once_t sPred = 0;
static FlutterStandardMessageCodec *sSharedObject = nil;
+ static dispatch_once_t sPred = 0;
dispatch_once(&sPred, ^{
FFSFileSelectorApiCodecReaderWriter *readerWriter =
[[FFSFileSelectorApiCodecReaderWriter alloc] init];
diff --git a/packages/file_selector/file_selector_ios/lib/src/messages.g.dart b/packages/file_selector/file_selector_ios/lib/src/messages.g.dart
index 4218474..2f38a68 100644
--- a/packages/file_selector/file_selector_ios/lib/src/messages.g.dart
+++ b/packages/file_selector/file_selector_ios/lib/src/messages.g.dart
@@ -1,13 +1,14 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Autogenerated from Pigeon (v3.2.5), do not edit directly.
+// Autogenerated from Pigeon (v9.1.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import
-import 'dart:async';
-import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List;
-import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer;
+import 'dart:async';
+import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
+
+import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
class FileSelectorConfig {
@@ -17,20 +18,21 @@
});
List<String?> utis;
+
bool allowMultiSelection;
Object encode() {
- final Map<Object?, Object?> pigeonMap = <Object?, Object?>{};
- pigeonMap['utis'] = utis;
- pigeonMap['allowMultiSelection'] = allowMultiSelection;
- return pigeonMap;
+ return <Object?>[
+ utis,
+ allowMultiSelection,
+ ];
}
- static FileSelectorConfig decode(Object message) {
- final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>;
+ static FileSelectorConfig decode(Object result) {
+ result as List<Object?>;
return FileSelectorConfig(
- utis: (pigeonMap['utis'] as List<Object?>?)!.cast<String?>(),
- allowMultiSelection: pigeonMap['allowMultiSelection']! as bool,
+ utis: (result[0] as List<Object?>?)!.cast<String?>(),
+ allowMultiSelection: result[1]! as bool,
);
}
}
@@ -52,7 +54,6 @@
switch (type) {
case 128:
return FileSelectorConfig.decode(readValue(buffer)!);
-
default:
return super.readValueOfType(type, buffer);
}
@@ -65,7 +66,6 @@
/// BinaryMessenger will be used which routes to the host platform.
FileSelectorApi({BinaryMessenger? binaryMessenger})
: _binaryMessenger = binaryMessenger;
-
final BinaryMessenger? _binaryMessenger;
static const MessageCodec<Object?> codec = _FileSelectorApiCodec();
@@ -74,28 +74,26 @@
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.FileSelectorApi.openFile', codec,
binaryMessenger: _binaryMessenger);
- final Map<Object?, Object?>? replyMap =
- await channel.send(<Object?>[arg_config]) as Map<Object?, Object?>?;
- if (replyMap == null) {
+ final List<Object?>? replyList =
+ await channel.send(<Object?>[arg_config]) as List<Object?>?;
+ if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
- } else if (replyMap['error'] != null) {
- final Map<Object?, Object?> error =
- (replyMap['error'] as Map<Object?, Object?>?)!;
+ } else if (replyList.length > 1) {
throw PlatformException(
- code: (error['code'] as String?)!,
- message: error['message'] as String?,
- details: error['details'],
+ code: replyList[0]! as String,
+ message: replyList[1] as String?,
+ details: replyList[2],
);
- } else if (replyMap['result'] == null) {
+ } else if (replyList[0] == null) {
throw PlatformException(
code: 'null-error',
message: 'Host platform returned null value for non-null return value.',
);
} else {
- return (replyMap['result'] as List<Object?>?)!.cast<String?>();
+ return (replyList[0] as List<Object?>?)!.cast<String?>();
}
}
}
diff --git a/packages/file_selector/file_selector_ios/pubspec.yaml b/packages/file_selector/file_selector_ios/pubspec.yaml
index 59c1daa..7e452fe 100644
--- a/packages/file_selector/file_selector_ios/pubspec.yaml
+++ b/packages/file_selector/file_selector_ios/pubspec.yaml
@@ -2,7 +2,7 @@
description: iOS implementation of the file_selector plugin.
repository: https://github.com/flutter/packages/tree/main/packages/file_selector/file_selector_ios
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
-version: 0.5.1+1
+version: 0.5.1+2
environment:
sdk: ">=2.18.0 <4.0.0"
@@ -22,9 +22,8 @@
sdk: flutter
dev_dependencies:
- build_runner: 2.1.11
+ build_runner: ^2.3.0
flutter_test:
sdk: flutter
mockito: 5.3.2
- pigeon: ^3.2.5
-
+ pigeon: ^9.1.0
diff --git a/packages/file_selector/file_selector_ios/test/test_api.g.dart b/packages/file_selector/file_selector_ios/test/test_api.g.dart
index 69f6c19..cf49eb1 100644
--- a/packages/file_selector/file_selector_ios/test/test_api.g.dart
+++ b/packages/file_selector/file_selector_ios/test/test_api.g.dart
@@ -1,19 +1,16 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Autogenerated from Pigeon (v3.2.5), do not edit directly.
+// Autogenerated from Pigeon (v9.1.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, unnecessary_import
// ignore_for_file: avoid_relative_lib_imports
import 'dart:async';
-import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List;
-import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer;
+import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
+import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
-// This line has been hand-edited due to
-// https://github.com/flutter/flutter/issues/97744
-// ignore: directives_ordering
import 'package:file_selector_ios/src/messages.g.dart';
class _TestFileSelectorApiCodec extends StandardMessageCodec {
@@ -33,7 +30,6 @@
switch (type) {
case 128:
return FileSelectorConfig.decode(readValue(buffer)!);
-
default:
return super.readValueOfType(type, buffer);
}
@@ -44,6 +40,7 @@
static const MessageCodec<Object?> codec = _TestFileSelectorApiCodec();
Future<List<String?>> openFile(FileSelectorConfig config);
+
static void setup(TestFileSelectorApi? api,
{BinaryMessenger? binaryMessenger}) {
{
@@ -62,7 +59,7 @@
assert(arg_config != null,
'Argument for dev.flutter.pigeon.FileSelectorApi.openFile was null, expected non-null FileSelectorConfig.');
final List<String?> output = await api.openFile(arg_config!);
- return <Object?, Object?>{'result': output};
+ return <Object?>[output];
});
}
}
diff --git a/packages/file_selector/file_selector_macos/CHANGELOG.md b/packages/file_selector/file_selector_macos/CHANGELOG.md
index 7bebb74..a02f6be 100644
--- a/packages/file_selector/file_selector_macos/CHANGELOG.md
+++ b/packages/file_selector/file_selector_macos/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.9.0+7
+
+* Updates to `pigeon` version 9.
+
## 0.9.0+6
* Clarifies explanation of endorsement in README.
diff --git a/packages/file_selector/file_selector_macos/example/macos/RunnerTests/RunnerTests.swift b/packages/file_selector/file_selector_macos/example/macos/RunnerTests/RunnerTests.swift
index 2dbd016..fcd39c6 100644
--- a/packages/file_selector/file_selector_macos/example/macos/RunnerTests/RunnerTests.swift
+++ b/packages/file_selector/file_selector_macos/example/macos/RunnerTests/RunnerTests.swift
@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-@testable import file_selector_macos
import FlutterMacOS
import XCTest
+@testable import file_selector_macos
+
class TestPanelController: NSObject, PanelController {
// The last panels that the relevant display methods were called on.
public var savePanel: NSSavePanel?
@@ -15,12 +16,17 @@
public var saveURL: URL?
public var openURLs: [URL]?
- func display(_ panel: NSSavePanel, for window: NSWindow?, completionHandler handler: @escaping (URL?) -> Void) {
+ func display(
+ _ panel: NSSavePanel, for window: NSWindow?, completionHandler handler: @escaping (URL?) -> Void
+ ) {
savePanel = panel
handler(saveURL)
}
- func display(_ panel: NSOpenPanel, for window: NSWindow?, completionHandler handler: @escaping ([URL]?) -> Void) {
+ func display(
+ _ panel: NSOpenPanel, for window: NSWindow?,
+ completionHandler handler: @escaping ([URL]?) -> Void
+ ) {
openPanel = panel
handler(openURLs)
}
@@ -28,9 +34,7 @@
class TestViewProvider: NSObject, ViewProvider {
var view: NSView? {
- get {
- window?.contentView
- }
+ window?.contentView
}
var window: NSWindow? = NSWindow()
}
@@ -52,8 +56,13 @@
canChooseDirectories: false,
canChooseFiles: true,
baseOptions: SavePanelOptions())
- plugin.displayOpenPanel(options: options) { paths in
- XCTAssertEqual(paths[0], returnPath)
+ plugin.displayOpenPanel(options: options) { result in
+ switch result {
+ case .success(let paths):
+ XCTAssertEqual(paths[0], returnPath)
+ case .failure(let error):
+ XCTFail("\(error)")
+ }
called.fulfill()
}
@@ -84,8 +93,13 @@
directoryPath: "/some/dir",
nameFieldStringValue: "a name",
prompt: "Open it!"))
- plugin.displayOpenPanel(options: options) { paths in
- XCTAssertEqual(paths[0], returnPath)
+ plugin.displayOpenPanel(options: options) { result in
+ switch result {
+ case .success(let paths):
+ XCTAssertEqual(paths[0], returnPath)
+ case .failure(let error):
+ XCTFail("\(error)")
+ }
called.fulfill()
}
@@ -113,10 +127,15 @@
canChooseDirectories: false,
canChooseFiles: true,
baseOptions: SavePanelOptions())
- plugin.displayOpenPanel(options: options) { paths in
- XCTAssertEqual(paths.count, returnPaths.count)
- XCTAssertEqual(paths[0], returnPaths[0])
- XCTAssertEqual(paths[1], returnPaths[1])
+ plugin.displayOpenPanel(options: options) { result in
+ switch result {
+ case .success(let paths):
+ XCTAssertEqual(paths.count, returnPaths.count)
+ XCTAssertEqual(paths[0], returnPaths[0])
+ XCTAssertEqual(paths[1], returnPaths[1])
+ case .failure(let error):
+ XCTFail("\(error)")
+ }
called.fulfill()
}
@@ -143,8 +162,13 @@
extensions: ["txt", "json"],
mimeTypes: [],
utis: ["public.text", "public.image"])))
- plugin.displayOpenPanel(options: options) { paths in
- XCTAssertEqual(paths[0], returnPath)
+ plugin.displayOpenPanel(options: options) { result in
+ switch result {
+ case .success(let paths):
+ XCTAssertEqual(paths[0], returnPath)
+ case .failure(let error):
+ XCTFail("\(error)")
+ }
called.fulfill()
}
@@ -167,8 +191,13 @@
canChooseDirectories: false,
canChooseFiles: true,
baseOptions: SavePanelOptions())
- plugin.displayOpenPanel(options: options) { paths in
- XCTAssertEqual(paths.count, 0)
+ plugin.displayOpenPanel(options: options) { result in
+ switch result {
+ case .success(let paths):
+ XCTAssertEqual(paths.count, 0)
+ case .failure(let error):
+ XCTFail("\(error)")
+ }
called.fulfill()
}
@@ -187,8 +216,13 @@
let called = XCTestExpectation()
let options = SavePanelOptions()
- plugin.displaySavePanel(options: options) { path in
- XCTAssertEqual(path, returnPath)
+ plugin.displaySavePanel(options: options) { result in
+ switch result {
+ case .success(let path):
+ XCTAssertEqual(path, returnPath)
+ case .failure(let error):
+ XCTFail("\(error)")
+ }
called.fulfill()
}
@@ -209,8 +243,13 @@
let options = SavePanelOptions(
directoryPath: "/some/dir",
prompt: "Save it!")
- plugin.displaySavePanel(options: options) { path in
- XCTAssertEqual(path, returnPath)
+ plugin.displaySavePanel(options: options) { result in
+ switch result {
+ case .success(let path):
+ XCTAssertEqual(path, returnPath)
+ case .failure(let error):
+ XCTFail("\(error)")
+ }
called.fulfill()
}
@@ -230,8 +269,13 @@
let called = XCTestExpectation()
let options = SavePanelOptions()
- plugin.displaySavePanel(options: options) { path in
- XCTAssertNil(path)
+ plugin.displaySavePanel(options: options) { result in
+ switch result {
+ case .success(let path):
+ XCTAssertNil(path)
+ case .failure(let error):
+ XCTFail("\(error)")
+ }
called.fulfill()
}
@@ -254,8 +298,13 @@
canChooseDirectories: true,
canChooseFiles: false,
baseOptions: SavePanelOptions())
- plugin.displayOpenPanel(options: options) { paths in
- XCTAssertEqual(paths[0], returnPath)
+ plugin.displayOpenPanel(options: options) { result in
+ switch result {
+ case .success(let paths):
+ XCTAssertEqual(paths[0], returnPath)
+ case .failure(let error):
+ XCTFail("\(error)")
+ }
called.fulfill()
}
@@ -283,8 +332,13 @@
canChooseDirectories: true,
canChooseFiles: false,
baseOptions: SavePanelOptions())
- plugin.displayOpenPanel(options: options) { paths in
- XCTAssertEqual(paths.count, 0)
+ plugin.displayOpenPanel(options: options) { result in
+ switch result {
+ case .success(let paths):
+ XCTAssertEqual(paths.count, 0)
+ case .failure(let error):
+ XCTFail("\(error)")
+ }
called.fulfill()
}
diff --git a/packages/file_selector/file_selector_macos/lib/src/messages.g.dart b/packages/file_selector/file_selector_macos/lib/src/messages.g.dart
index 5f1daf9..325afd1 100644
--- a/packages/file_selector/file_selector_macos/lib/src/messages.g.dart
+++ b/packages/file_selector/file_selector_macos/lib/src/messages.g.dart
@@ -1,9 +1,10 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Autogenerated from Pigeon (v4.2.14), do not edit directly.
+// Autogenerated from Pigeon (v9.1.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import
+
import 'dart:async';
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
@@ -146,13 +147,10 @@
switch (type) {
case 128:
return AllowedTypes.decode(readValue(buffer)!);
-
case 129:
return OpenPanelOptions.decode(readValue(buffer)!);
-
case 130:
return SavePanelOptions.decode(readValue(buffer)!);
-
default:
return super.readValueOfType(type, buffer);
}
diff --git a/packages/file_selector/file_selector_macos/macos/Classes/FileSelectorPlugin.swift b/packages/file_selector/file_selector_macos/macos/Classes/FileSelectorPlugin.swift
index 4e1c935..836fcf9 100644
--- a/packages/file_selector/file_selector_macos/macos/Classes/FileSelectorPlugin.swift
+++ b/packages/file_selector/file_selector_macos/macos/Classes/FileSelectorPlugin.swift
@@ -16,7 +16,7 @@
func display(
_ panel: NSSavePanel,
for window: NSWindow?,
- completionHandler: @escaping (URL?) -> Void);
+ completionHandler: @escaping (URL?) -> Void)
/// Displays the given open panel, and provides the selected URLs, or nil if the panel is
/// cancelled, to the handler.
@@ -27,7 +27,7 @@
func display(
_ panel: NSOpenPanel,
for window: NSWindow?,
- completionHandler: @escaping ([URL]?) -> Void);
+ completionHandler: @escaping ([URL]?) -> Void)
}
/// Protocol to provide access to the Flutter view, allowing for dependency injection in tests.
@@ -60,20 +60,23 @@
self.panelController = panelController
}
- func displayOpenPanel(options: OpenPanelOptions, completion: @escaping ([String?]) -> Void) {
-
+ func displayOpenPanel(
+ options: OpenPanelOptions, completion: @escaping (Result<[String?], Error>) -> Void
+ ) {
let panel = NSOpenPanel()
configure(openPanel: panel, with: options)
panelController.display(panel, for: viewProvider.view?.window) { (selection: [URL]?) in
- completion(selection?.map({ item in item.path }) ?? [])
+ completion(.success(selection?.map({ item in item.path }) ?? []))
}
}
- func displaySavePanel(options: SavePanelOptions, completion: @escaping (String?) -> Void) {
+ func displaySavePanel(
+ options: SavePanelOptions, completion: @escaping (Result<String?, Error>) -> Void
+ ) {
let panel = NSSavePanel()
configure(panel: panel, with: options)
panelController.display(panel, for: viewProvider.view?.window) { (selection: URL?) in
- completion(selection?.path)
+ completion(.success(selection?.path))
}
}
@@ -118,8 +121,8 @@
) {
configure(panel: panel, with: options.baseOptions)
panel.allowsMultipleSelection = options.allowsMultipleSelection
- panel.canChooseDirectories = options.canChooseDirectories;
- panel.canChooseFiles = options.canChooseFiles;
+ panel.canChooseDirectories = options.canChooseDirectories
+ panel.canChooseFiles = options.canChooseFiles
}
}
@@ -166,8 +169,6 @@
}
var view: NSView? {
- get {
- registrar.view
- }
+ registrar.view
}
}
diff --git a/packages/file_selector/file_selector_macos/macos/Classes/messages.g.swift b/packages/file_selector/file_selector_macos/macos/Classes/messages.g.swift
index 75753d9..5303e81 100644
--- a/packages/file_selector/file_selector_macos/macos/Classes/messages.g.swift
+++ b/packages/file_selector/file_selector_macos/macos/Classes/messages.g.swift
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Autogenerated from Pigeon (v4.2.14), do not edit directly.
+// Autogenerated from Pigeon (v9.1.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon
import Foundation
@@ -14,7 +14,25 @@
#endif
-/// Generated class from Pigeon.
+
+private func wrapResult(_ result: Any?) -> [Any?] {
+ return [result]
+}
+
+private func wrapError(_ error: Any) -> [Any?] {
+ if let flutterError = error as? FlutterError {
+ return [
+ flutterError.code,
+ flutterError.message,
+ flutterError.details
+ ]
+ }
+ return [
+ "\(error)",
+ "\(type(of: error))",
+ "Stacktrace: \(Thread.callStackSymbols)"
+ ]
+}
/// A Pigeon representation of the macOS portion of an `XTypeGroup`.
///
@@ -24,7 +42,7 @@
var mimeTypes: [String?]
var utis: [String?]
- static func fromList(_ list: [Any?]) -> AllowedTypes? {
+ static func fromList(_ list: [Any]) -> AllowedTypes? {
let extensions = list[0] as! [String?]
let mimeTypes = list[1] as! [String?]
let utis = list[2] as! [String?]
@@ -56,14 +74,14 @@
var nameFieldStringValue: String? = nil
var prompt: String? = nil
- static func fromList(_ list: [Any?]) -> SavePanelOptions? {
+ static func fromList(_ list: [Any]) -> SavePanelOptions? {
var allowedFileTypes: AllowedTypes? = nil
- if let allowedFileTypesList = list[0] as? [Any?] {
- allowedFileTypes = AllowedTypes.fromList(allowedFileTypesList)
+ if let allowedFileTypesList = list[0] as! [Any]? {
+ allowedFileTypes = AllowedTypes.fromList(allowedFileTypesList as [Any])
}
- let directoryPath = list[1] as? String
- let nameFieldStringValue = list[2] as? String
- let prompt = list[3] as? String
+ let directoryPath = list[1] as! String?
+ let nameFieldStringValue = list[2] as! String?
+ let prompt = list[3] as! String?
return SavePanelOptions(
allowedFileTypes: allowedFileTypes,
@@ -93,11 +111,11 @@
var canChooseFiles: Bool
var baseOptions: SavePanelOptions
- static func fromList(_ list: [Any?]) -> OpenPanelOptions? {
+ static func fromList(_ list: [Any]) -> OpenPanelOptions? {
let allowsMultipleSelection = list[0] as! Bool
let canChooseDirectories = list[1] as! Bool
let canChooseFiles = list[2] as! Bool
- let baseOptions = SavePanelOptions.fromList(list[3] as! [Any?])!
+ let baseOptions = SavePanelOptions.fromList(list[3] as! [Any])!
return OpenPanelOptions(
allowsMultipleSelection: allowsMultipleSelection,
@@ -120,17 +138,17 @@
override func readValue(ofType type: UInt8) -> Any? {
switch type {
case 128:
- return AllowedTypes.fromList(self.readValue() as! [Any])
+ return AllowedTypes.fromList(self.readValue() as! [Any])
case 129:
- return OpenPanelOptions.fromList(self.readValue() as! [Any])
+ return OpenPanelOptions.fromList(self.readValue() as! [Any])
case 130:
- return SavePanelOptions.fromList(self.readValue() as! [Any])
+ return SavePanelOptions.fromList(self.readValue() as! [Any])
default:
return super.readValue(ofType: type)
-
}
}
}
+
private class FileSelectorApiCodecWriter: FlutterStandardWriter {
override func writeValue(_ value: Any) {
if let value = value as? AllowedTypes {
@@ -168,11 +186,11 @@
/// selected paths.
///
/// An empty list corresponds to a cancelled selection.
- func displayOpenPanel(options: OpenPanelOptions, completion: @escaping ([String?]) -> Void)
+ func displayOpenPanel(options: OpenPanelOptions, completion: @escaping (Result<[String?], Error>) -> Void)
/// Shows a save panel with the given [options], returning the selected path.
///
/// A null return corresponds to a cancelled save.
- func displaySavePanel(options: SavePanelOptions, completion: @escaping (String?) -> Void)
+ func displaySavePanel(options: SavePanelOptions, completion: @escaping (Result<String?, Error>) -> Void)
}
/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.
@@ -188,10 +206,15 @@
let displayOpenPanelChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FileSelectorApi.displayOpenPanel", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
displayOpenPanelChannel.setMessageHandler { message, reply in
- let args = message as! [Any?]
+ let args = message as! [Any]
let optionsArg = args[0] as! OpenPanelOptions
api.displayOpenPanel(options: optionsArg) { result in
- reply(wrapResult(result))
+ switch result {
+ case .success(let res):
+ reply(wrapResult(res))
+ case .failure(let error):
+ reply(wrapError(error))
+ }
}
}
} else {
@@ -203,10 +226,15 @@
let displaySavePanelChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FileSelectorApi.displaySavePanel", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
displaySavePanelChannel.setMessageHandler { message, reply in
- let args = message as! [Any?]
+ let args = message as! [Any]
let optionsArg = args[0] as! SavePanelOptions
api.displaySavePanel(options: optionsArg) { result in
- reply(wrapResult(result))
+ switch result {
+ case .success(let res):
+ reply(wrapResult(res))
+ case .failure(let error):
+ reply(wrapError(error))
+ }
}
}
} else {
@@ -214,15 +242,3 @@
}
}
}
-
-private func wrapResult(_ result: Any?) -> [Any?] {
- return [result]
-}
-
-private func wrapError(_ error: FlutterError) -> [Any?] {
- return [
- error.code,
- error.message,
- error.details
- ]
-}
diff --git a/packages/file_selector/file_selector_macos/pubspec.yaml b/packages/file_selector/file_selector_macos/pubspec.yaml
index 073adbb..da99217 100644
--- a/packages/file_selector/file_selector_macos/pubspec.yaml
+++ b/packages/file_selector/file_selector_macos/pubspec.yaml
@@ -2,7 +2,7 @@
description: macOS implementation of the file_selector plugin.
repository: https://github.com/flutter/packages/tree/main/packages/file_selector/file_selector_macos
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
-version: 0.9.0+6
+version: 0.9.0+7
environment:
sdk: ">=2.17.0 <4.0.0"
@@ -27,4 +27,4 @@
flutter_test:
sdk: flutter
mockito: 5.3.2
- pigeon: ^4.2.14
+ pigeon: ^9.1.0
diff --git a/packages/file_selector/file_selector_macos/test/messages_test.g.dart b/packages/file_selector/file_selector_macos/test/messages_test.g.dart
index 731f1fb..0c67c79 100644
--- a/packages/file_selector/file_selector_macos/test/messages_test.g.dart
+++ b/packages/file_selector/file_selector_macos/test/messages_test.g.dart
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Autogenerated from Pigeon (v4.2.14), do not edit directly.
+// Autogenerated from Pigeon (v9.1.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, unnecessary_import
// ignore_for_file: avoid_relative_lib_imports
@@ -36,13 +36,10 @@
switch (type) {
case 128:
return AllowedTypes.decode(readValue(buffer)!);
-
case 129:
return OpenPanelOptions.decode(readValue(buffer)!);
-
case 130:
return SavePanelOptions.decode(readValue(buffer)!);
-
default:
return super.readValueOfType(type, buffer);
}
diff --git a/packages/file_selector/file_selector_windows/CHANGELOG.md b/packages/file_selector/file_selector_windows/CHANGELOG.md
index 2972463..b3c41ba 100644
--- a/packages/file_selector/file_selector_windows/CHANGELOG.md
+++ b/packages/file_selector/file_selector_windows/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.9.1+7
+
+* Updates to `pigeon` version 9.
+
## 0.9.1+6
* Clarifies explanation of endorsement in README.
diff --git a/packages/file_selector/file_selector_windows/lib/src/messages.g.dart b/packages/file_selector/file_selector_windows/lib/src/messages.g.dart
index ad3d5af..a61076b 100644
--- a/packages/file_selector/file_selector_windows/lib/src/messages.g.dart
+++ b/packages/file_selector/file_selector_windows/lib/src/messages.g.dart
@@ -1,13 +1,14 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Autogenerated from Pigeon (v3.2.5), do not edit directly.
+// Autogenerated from Pigeon (v9.1.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import
-import 'dart:async';
-import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List;
-import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer;
+import 'dart:async';
+import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
+
+import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
class TypeGroup {
@@ -17,20 +18,21 @@
});
String label;
+
List<String?> extensions;
Object encode() {
- final Map<Object?, Object?> pigeonMap = <Object?, Object?>{};
- pigeonMap['label'] = label;
- pigeonMap['extensions'] = extensions;
- return pigeonMap;
+ return <Object?>[
+ label,
+ extensions,
+ ];
}
- static TypeGroup decode(Object message) {
- final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>;
+ static TypeGroup decode(Object result) {
+ result as List<Object?>;
return TypeGroup(
- label: pigeonMap['label']! as String,
- extensions: (pigeonMap['extensions'] as List<Object?>?)!.cast<String?>(),
+ label: result[0]! as String,
+ extensions: (result[1] as List<Object?>?)!.cast<String?>(),
);
}
}
@@ -43,24 +45,25 @@
});
bool allowMultiple;
+
bool selectFolders;
+
List<TypeGroup?> allowedTypes;
Object encode() {
- final Map<Object?, Object?> pigeonMap = <Object?, Object?>{};
- pigeonMap['allowMultiple'] = allowMultiple;
- pigeonMap['selectFolders'] = selectFolders;
- pigeonMap['allowedTypes'] = allowedTypes;
- return pigeonMap;
+ return <Object?>[
+ allowMultiple,
+ selectFolders,
+ allowedTypes,
+ ];
}
- static SelectionOptions decode(Object message) {
- final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>;
+ static SelectionOptions decode(Object result) {
+ result as List<Object?>;
return SelectionOptions(
- allowMultiple: pigeonMap['allowMultiple']! as bool,
- selectFolders: pigeonMap['selectFolders']! as bool,
- allowedTypes:
- (pigeonMap['allowedTypes'] as List<Object?>?)!.cast<TypeGroup?>(),
+ allowMultiple: result[0]! as bool,
+ selectFolders: result[1]! as bool,
+ allowedTypes: (result[2] as List<Object?>?)!.cast<TypeGroup?>(),
);
}
}
@@ -85,10 +88,8 @@
switch (type) {
case 128:
return SelectionOptions.decode(readValue(buffer)!);
-
case 129:
return TypeGroup.decode(readValue(buffer)!);
-
default:
return super.readValueOfType(type, buffer);
}
@@ -101,7 +102,6 @@
/// BinaryMessenger will be used which routes to the host platform.
FileSelectorApi({BinaryMessenger? binaryMessenger})
: _binaryMessenger = binaryMessenger;
-
final BinaryMessenger? _binaryMessenger;
static const MessageCodec<Object?> codec = _FileSelectorApiCodec();
@@ -111,29 +111,27 @@
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.FileSelectorApi.showOpenDialog', codec,
binaryMessenger: _binaryMessenger);
- final Map<Object?, Object?>? replyMap = await channel.send(
+ final List<Object?>? replyList = await channel.send(
<Object?>[arg_options, arg_initialDirectory, arg_confirmButtonText])
- as Map<Object?, Object?>?;
- if (replyMap == null) {
+ as List<Object?>?;
+ if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
- } else if (replyMap['error'] != null) {
- final Map<Object?, Object?> error =
- (replyMap['error'] as Map<Object?, Object?>?)!;
+ } else if (replyList.length > 1) {
throw PlatformException(
- code: (error['code'] as String?)!,
- message: error['message'] as String?,
- details: error['details'],
+ code: replyList[0]! as String,
+ message: replyList[1] as String?,
+ details: replyList[2],
);
- } else if (replyMap['result'] == null) {
+ } else if (replyList[0] == null) {
throw PlatformException(
code: 'null-error',
message: 'Host platform returned null value for non-null return value.',
);
} else {
- return (replyMap['result'] as List<Object?>?)!.cast<String?>();
+ return (replyList[0] as List<Object?>?)!.cast<String?>();
}
}
@@ -145,32 +143,30 @@
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.FileSelectorApi.showSaveDialog', codec,
binaryMessenger: _binaryMessenger);
- final Map<Object?, Object?>? replyMap = await channel.send(<Object?>[
+ final List<Object?>? replyList = await channel.send(<Object?>[
arg_options,
arg_initialDirectory,
arg_suggestedName,
arg_confirmButtonText
- ]) as Map<Object?, Object?>?;
- if (replyMap == null) {
+ ]) as List<Object?>?;
+ if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
- } else if (replyMap['error'] != null) {
- final Map<Object?, Object?> error =
- (replyMap['error'] as Map<Object?, Object?>?)!;
+ } else if (replyList.length > 1) {
throw PlatformException(
- code: (error['code'] as String?)!,
- message: error['message'] as String?,
- details: error['details'],
+ code: replyList[0]! as String,
+ message: replyList[1] as String?,
+ details: replyList[2],
);
- } else if (replyMap['result'] == null) {
+ } else if (replyList[0] == null) {
throw PlatformException(
code: 'null-error',
message: 'Host platform returned null value for non-null return value.',
);
} else {
- return (replyMap['result'] as List<Object?>?)!.cast<String?>();
+ return (replyList[0] as List<Object?>?)!.cast<String?>();
}
}
}
diff --git a/packages/file_selector/file_selector_windows/pubspec.yaml b/packages/file_selector/file_selector_windows/pubspec.yaml
index a93ab0f..faf4239 100644
--- a/packages/file_selector/file_selector_windows/pubspec.yaml
+++ b/packages/file_selector/file_selector_windows/pubspec.yaml
@@ -2,7 +2,7 @@
description: Windows implementation of the file_selector plugin.
repository: https://github.com/flutter/packages/tree/main/packages/file_selector/file_selector_windows
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
-version: 0.9.1+6
+version: 0.9.1+7
environment:
sdk: ">=2.17.0 <4.0.0"
@@ -23,8 +23,8 @@
sdk: flutter
dev_dependencies:
- build_runner: 2.1.11
+ build_runner: ^2.3.0
flutter_test:
sdk: flutter
mockito: 5.3.2
- pigeon: ^3.2.5
+ pigeon: ^9.1.0
diff --git a/packages/file_selector/file_selector_windows/test/test_api.g.dart b/packages/file_selector/file_selector_windows/test/test_api.g.dart
index f9b979f..f9ed8e5 100644
--- a/packages/file_selector/file_selector_windows/test/test_api.g.dart
+++ b/packages/file_selector/file_selector_windows/test/test_api.g.dart
@@ -1,17 +1,16 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Autogenerated from Pigeon (v3.2.5), do not edit directly.
+// Autogenerated from Pigeon (v9.1.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, unnecessary_import
// ignore_for_file: avoid_relative_lib_imports
import 'dart:async';
-import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List;
-import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer;
+import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
+import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
-// ignore: directives_ordering
import 'package:file_selector_windows/src/messages.g.dart';
class _TestFileSelectorApiCodec extends StandardMessageCodec {
@@ -34,10 +33,8 @@
switch (type) {
case 128:
return SelectionOptions.decode(readValue(buffer)!);
-
case 129:
return TypeGroup.decode(readValue(buffer)!);
-
default:
return super.readValueOfType(type, buffer);
}
@@ -49,11 +46,13 @@
List<String?> showOpenDialog(SelectionOptions options,
String? initialDirectory, String? confirmButtonText);
+
List<String?> showSaveDialog(
SelectionOptions options,
String? initialDirectory,
String? suggestedName,
String? confirmButtonText);
+
static void setup(TestFileSelectorApi? api,
{BinaryMessenger? binaryMessenger}) {
{
@@ -74,7 +73,7 @@
final String? arg_confirmButtonText = (args[2] as String?);
final List<String?> output = api.showOpenDialog(
arg_options!, arg_initialDirectory, arg_confirmButtonText);
- return <Object?, Object?>{'result': output};
+ return <Object?>[output];
});
}
}
@@ -97,7 +96,7 @@
final String? arg_confirmButtonText = (args[3] as String?);
final List<String?> output = api.showSaveDialog(arg_options!,
arg_initialDirectory, arg_suggestedName, arg_confirmButtonText);
- return <Object?, Object?>{'result': output};
+ return <Object?>[output];
});
}
}
diff --git a/packages/file_selector/file_selector_windows/windows/messages.g.cpp b/packages/file_selector/file_selector_windows/windows/messages.g.cpp
index 04e529d..24b831e 100644
--- a/packages/file_selector/file_selector_windows/windows/messages.g.cpp
+++ b/packages/file_selector/file_selector_windows/windows/messages.g.cpp
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Autogenerated from Pigeon (v3.2.5), do not edit directly.
+// Autogenerated from Pigeon (v9.1.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon
#undef _HAS_EXCEPTIONS
@@ -18,43 +18,46 @@
#include <string>
namespace file_selector_windows {
+using flutter::BasicMessageChannel;
+using flutter::CustomEncodableValue;
+using flutter::EncodableList;
+using flutter::EncodableMap;
+using flutter::EncodableValue;
-/* TypeGroup */
+// TypeGroup
const std::string& TypeGroup::label() const { return label_; }
void TypeGroup::set_label(std::string_view value_arg) { label_ = value_arg; }
-const flutter::EncodableList& TypeGroup::extensions() const {
- return extensions_;
-}
-void TypeGroup::set_extensions(const flutter::EncodableList& value_arg) {
+const EncodableList& TypeGroup::extensions() const { return extensions_; }
+void TypeGroup::set_extensions(const EncodableList& value_arg) {
extensions_ = value_arg;
}
-flutter::EncodableMap TypeGroup::ToEncodableMap() const {
- return flutter::EncodableMap{
- {flutter::EncodableValue("label"), flutter::EncodableValue(label_)},
- {flutter::EncodableValue("extensions"),
- flutter::EncodableValue(extensions_)},
- };
+EncodableList TypeGroup::ToEncodableList() const {
+ EncodableList list;
+ list.reserve(2);
+ list.push_back(EncodableValue(label_));
+ list.push_back(EncodableValue(extensions_));
+ return list;
}
TypeGroup::TypeGroup() {}
-TypeGroup::TypeGroup(flutter::EncodableMap map) {
- auto& encodable_label = map.at(flutter::EncodableValue("label"));
+TypeGroup::TypeGroup(const EncodableList& list) {
+ auto& encodable_label = list[0];
if (const std::string* pointer_label =
std::get_if<std::string>(&encodable_label)) {
label_ = *pointer_label;
}
- auto& encodable_extensions = map.at(flutter::EncodableValue("extensions"));
- if (const flutter::EncodableList* pointer_extensions =
- std::get_if<flutter::EncodableList>(&encodable_extensions)) {
+ auto& encodable_extensions = list[1];
+ if (const EncodableList* pointer_extensions =
+ std::get_if<EncodableList>(&encodable_extensions)) {
extensions_ = *pointer_extensions;
}
}
-/* SelectionOptions */
+// SelectionOptions
bool SelectionOptions::allow_multiple() const { return allow_multiple_; }
void SelectionOptions::set_allow_multiple(bool value_arg) {
@@ -66,80 +69,73 @@
select_folders_ = value_arg;
}
-const flutter::EncodableList& SelectionOptions::allowed_types() const {
+const EncodableList& SelectionOptions::allowed_types() const {
return allowed_types_;
}
-void SelectionOptions::set_allowed_types(
- const flutter::EncodableList& value_arg) {
+void SelectionOptions::set_allowed_types(const EncodableList& value_arg) {
allowed_types_ = value_arg;
}
-flutter::EncodableMap SelectionOptions::ToEncodableMap() const {
- return flutter::EncodableMap{
- {flutter::EncodableValue("allowMultiple"),
- flutter::EncodableValue(allow_multiple_)},
- {flutter::EncodableValue("selectFolders"),
- flutter::EncodableValue(select_folders_)},
- {flutter::EncodableValue("allowedTypes"),
- flutter::EncodableValue(allowed_types_)},
- };
+EncodableList SelectionOptions::ToEncodableList() const {
+ EncodableList list;
+ list.reserve(3);
+ list.push_back(EncodableValue(allow_multiple_));
+ list.push_back(EncodableValue(select_folders_));
+ list.push_back(EncodableValue(allowed_types_));
+ return list;
}
SelectionOptions::SelectionOptions() {}
-SelectionOptions::SelectionOptions(flutter::EncodableMap map) {
- auto& encodable_allow_multiple =
- map.at(flutter::EncodableValue("allowMultiple"));
+SelectionOptions::SelectionOptions(const EncodableList& list) {
+ auto& encodable_allow_multiple = list[0];
if (const bool* pointer_allow_multiple =
std::get_if<bool>(&encodable_allow_multiple)) {
allow_multiple_ = *pointer_allow_multiple;
}
- auto& encodable_select_folders =
- map.at(flutter::EncodableValue("selectFolders"));
+ auto& encodable_select_folders = list[1];
if (const bool* pointer_select_folders =
std::get_if<bool>(&encodable_select_folders)) {
select_folders_ = *pointer_select_folders;
}
- auto& encodable_allowed_types =
- map.at(flutter::EncodableValue("allowedTypes"));
- if (const flutter::EncodableList* pointer_allowed_types =
- std::get_if<flutter::EncodableList>(&encodable_allowed_types)) {
+ auto& encodable_allowed_types = list[2];
+ if (const EncodableList* pointer_allowed_types =
+ std::get_if<EncodableList>(&encodable_allowed_types)) {
allowed_types_ = *pointer_allowed_types;
}
}
FileSelectorApiCodecSerializer::FileSelectorApiCodecSerializer() {}
-flutter::EncodableValue FileSelectorApiCodecSerializer::ReadValueOfType(
+EncodableValue FileSelectorApiCodecSerializer::ReadValueOfType(
uint8_t type, flutter::ByteStreamReader* stream) const {
switch (type) {
case 128:
- return flutter::CustomEncodableValue(
- SelectionOptions(std::get<flutter::EncodableMap>(ReadValue(stream))));
-
+ return CustomEncodableValue(
+ SelectionOptions(std::get<EncodableList>(ReadValue(stream))));
case 129:
- return flutter::CustomEncodableValue(
- TypeGroup(std::get<flutter::EncodableMap>(ReadValue(stream))));
-
+ return CustomEncodableValue(
+ TypeGroup(std::get<EncodableList>(ReadValue(stream))));
default:
return flutter::StandardCodecSerializer::ReadValueOfType(type, stream);
}
}
void FileSelectorApiCodecSerializer::WriteValue(
- const flutter::EncodableValue& value,
- flutter::ByteStreamWriter* stream) const {
- if (const flutter::CustomEncodableValue* custom_value =
- std::get_if<flutter::CustomEncodableValue>(&value)) {
+ const EncodableValue& value, flutter::ByteStreamWriter* stream) const {
+ if (const CustomEncodableValue* custom_value =
+ std::get_if<CustomEncodableValue>(&value)) {
if (custom_value->type() == typeid(SelectionOptions)) {
stream->WriteByte(128);
WriteValue(
- std::any_cast<SelectionOptions>(*custom_value).ToEncodableMap(),
+ EncodableValue(
+ std::any_cast<SelectionOptions>(*custom_value).ToEncodableList()),
stream);
return;
}
if (custom_value->type() == typeid(TypeGroup)) {
stream->WriteByte(129);
- WriteValue(std::any_cast<TypeGroup>(*custom_value).ToEncodableMap(),
+ WriteValue(EncodableValue(
+ std::any_cast<TypeGroup>(*custom_value).ToEncodableList()),
stream);
return;
}
@@ -147,86 +143,73 @@
flutter::StandardCodecSerializer::WriteValue(value, stream);
}
-/** The codec used by FileSelectorApi. */
+/// The codec used by FileSelectorApi.
const flutter::StandardMessageCodec& FileSelectorApi::GetCodec() {
return flutter::StandardMessageCodec::GetInstance(
&FileSelectorApiCodecSerializer::GetInstance());
}
-/** Sets up an instance of `FileSelectorApi` to handle messages through the
- * `binary_messenger`. */
+// Sets up an instance of `FileSelectorApi` to handle messages through the
+// `binary_messenger`.
void FileSelectorApi::SetUp(flutter::BinaryMessenger* binary_messenger,
FileSelectorApi* api) {
{
- auto channel =
- std::make_unique<flutter::BasicMessageChannel<flutter::EncodableValue>>(
- binary_messenger,
- "dev.flutter.pigeon.FileSelectorApi.showOpenDialog", &GetCodec());
+ auto channel = std::make_unique<BasicMessageChannel<>>(
+ binary_messenger, "dev.flutter.pigeon.FileSelectorApi.showOpenDialog",
+ &GetCodec());
if (api != nullptr) {
channel->SetMessageHandler(
- [api](const flutter::EncodableValue& message,
- const flutter::MessageReply<flutter::EncodableValue>& reply) {
- flutter::EncodableMap wrapped;
+ [api](const EncodableValue& message,
+ const flutter::MessageReply<EncodableValue>& reply) {
try {
- const auto& args = std::get<flutter::EncodableList>(message);
+ const auto& args = std::get<EncodableList>(message);
const auto& encodable_options_arg = args.at(0);
if (encodable_options_arg.IsNull()) {
- wrapped.emplace(flutter::EncodableValue("error"),
- WrapError("options_arg unexpectedly null."));
- reply(wrapped);
+ reply(WrapError("options_arg unexpectedly null."));
return;
}
const auto& options_arg = std::any_cast<const SelectionOptions&>(
- std::get<flutter::CustomEncodableValue>(
- encodable_options_arg));
+ std::get<CustomEncodableValue>(encodable_options_arg));
const auto& encodable_initial_directory_arg = args.at(1);
const auto* initial_directory_arg =
std::get_if<std::string>(&encodable_initial_directory_arg);
const auto& encodable_confirm_button_text_arg = args.at(2);
const auto* confirm_button_text_arg =
std::get_if<std::string>(&encodable_confirm_button_text_arg);
- ErrorOr<flutter::EncodableList> output = api->ShowOpenDialog(
+ ErrorOr<EncodableList> output = api->ShowOpenDialog(
options_arg, initial_directory_arg, confirm_button_text_arg);
if (output.has_error()) {
- wrapped.emplace(flutter::EncodableValue("error"),
- WrapError(output.error()));
- } else {
- wrapped.emplace(
- flutter::EncodableValue("result"),
- flutter::EncodableValue(std::move(output).TakeValue()));
+ reply(WrapError(output.error()));
+ return;
}
+ EncodableList wrapped;
+ wrapped.push_back(EncodableValue(std::move(output).TakeValue()));
+ reply(EncodableValue(std::move(wrapped)));
} catch (const std::exception& exception) {
- wrapped.emplace(flutter::EncodableValue("error"),
- WrapError(exception.what()));
+ reply(WrapError(exception.what()));
}
- reply(wrapped);
});
} else {
channel->SetMessageHandler(nullptr);
}
}
{
- auto channel =
- std::make_unique<flutter::BasicMessageChannel<flutter::EncodableValue>>(
- binary_messenger,
- "dev.flutter.pigeon.FileSelectorApi.showSaveDialog", &GetCodec());
+ auto channel = std::make_unique<BasicMessageChannel<>>(
+ binary_messenger, "dev.flutter.pigeon.FileSelectorApi.showSaveDialog",
+ &GetCodec());
if (api != nullptr) {
channel->SetMessageHandler(
- [api](const flutter::EncodableValue& message,
- const flutter::MessageReply<flutter::EncodableValue>& reply) {
- flutter::EncodableMap wrapped;
+ [api](const EncodableValue& message,
+ const flutter::MessageReply<EncodableValue>& reply) {
try {
- const auto& args = std::get<flutter::EncodableList>(message);
+ const auto& args = std::get<EncodableList>(message);
const auto& encodable_options_arg = args.at(0);
if (encodable_options_arg.IsNull()) {
- wrapped.emplace(flutter::EncodableValue("error"),
- WrapError("options_arg unexpectedly null."));
- reply(wrapped);
+ reply(WrapError("options_arg unexpectedly null."));
return;
}
const auto& options_arg = std::any_cast<const SelectionOptions&>(
- std::get<flutter::CustomEncodableValue>(
- encodable_options_arg));
+ std::get<CustomEncodableValue>(encodable_options_arg));
const auto& encodable_initial_directory_arg = args.at(1);
const auto* initial_directory_arg =
std::get_if<std::string>(&encodable_initial_directory_arg);
@@ -236,22 +219,19 @@
const auto& encodable_confirm_button_text_arg = args.at(3);
const auto* confirm_button_text_arg =
std::get_if<std::string>(&encodable_confirm_button_text_arg);
- ErrorOr<flutter::EncodableList> output = api->ShowSaveDialog(
+ ErrorOr<EncodableList> output = api->ShowSaveDialog(
options_arg, initial_directory_arg, suggested_name_arg,
confirm_button_text_arg);
if (output.has_error()) {
- wrapped.emplace(flutter::EncodableValue("error"),
- WrapError(output.error()));
- } else {
- wrapped.emplace(
- flutter::EncodableValue("result"),
- flutter::EncodableValue(std::move(output).TakeValue()));
+ reply(WrapError(output.error()));
+ return;
}
+ EncodableList wrapped;
+ wrapped.push_back(EncodableValue(std::move(output).TakeValue()));
+ reply(EncodableValue(std::move(wrapped)));
} catch (const std::exception& exception) {
- wrapped.emplace(flutter::EncodableValue("error"),
- WrapError(exception.what()));
+ reply(WrapError(exception.what()));
}
- reply(wrapped);
});
} else {
channel->SetMessageHandler(nullptr);
@@ -259,20 +239,15 @@
}
}
-flutter::EncodableMap FileSelectorApi::WrapError(
- std::string_view error_message) {
- return flutter::EncodableMap(
- {{flutter::EncodableValue("message"),
- flutter::EncodableValue(std::string(error_message))},
- {flutter::EncodableValue("code"), flutter::EncodableValue("Error")},
- {flutter::EncodableValue("details"), flutter::EncodableValue()}});
+EncodableValue FileSelectorApi::WrapError(std::string_view error_message) {
+ return EncodableValue(
+ EncodableList{EncodableValue(std::string(error_message)),
+ EncodableValue("Error"), EncodableValue()});
}
-flutter::EncodableMap FileSelectorApi::WrapError(const FlutterError& error) {
- return flutter::EncodableMap(
- {{flutter::EncodableValue("message"),
- flutter::EncodableValue(error.message())},
- {flutter::EncodableValue("code"), flutter::EncodableValue(error.code())},
- {flutter::EncodableValue("details"), error.details()}});
+EncodableValue FileSelectorApi::WrapError(const FlutterError& error) {
+ return EncodableValue(EncodableList{EncodableValue(error.code()),
+ EncodableValue(error.message()),
+ error.details()});
}
} // namespace file_selector_windows
diff --git a/packages/file_selector/file_selector_windows/windows/messages.g.h b/packages/file_selector/file_selector_windows/windows/messages.g.h
index fb496d2..248ca89 100644
--- a/packages/file_selector/file_selector_windows/windows/messages.g.h
+++ b/packages/file_selector/file_selector_windows/windows/messages.g.h
@@ -1,11 +1,11 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Autogenerated from Pigeon (v3.2.5), do not edit directly.
+// Autogenerated from Pigeon (v9.1.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon
-#ifndef PIGEON_MESSAGES_G_FILE_SELECTOR_WINDOWS_H_
-#define PIGEON_MESSAGES_G_FILE_SELECTOR_WINDOWS_H_
+#ifndef PIGEON_MESSAGES_G_H_
+#define PIGEON_MESSAGES_G_H_
#include <flutter/basic_message_channel.h>
#include <flutter/binary_messenger.h>
#include <flutter/encodable_value.h>
@@ -17,15 +17,15 @@
namespace file_selector_windows {
-/* Generated class from Pigeon. */
+// Generated class from Pigeon.
class FlutterError {
public:
- FlutterError(const std::string& code) : code_(code) {}
- FlutterError(const std::string& code, const std::string& message)
+ explicit FlutterError(const std::string& code) : code_(code) {}
+ explicit FlutterError(const std::string& code, const std::string& message)
: code_(code), message_(message) {}
- FlutterError(const std::string& code, const std::string& message,
- const flutter::EncodableValue& details)
+ explicit FlutterError(const std::string& code, const std::string& message,
+ const flutter::EncodableValue& details)
: code_(code), message_(message), details_(details) {}
const std::string& code() const { return code_; }
@@ -58,7 +58,7 @@
std::variant<T, FlutterError> v_;
};
-/* Generated class from Pigeon that represents data sent in messages. */
+// Generated class from Pigeon that represents data sent in messages.
class TypeGroup {
public:
TypeGroup();
@@ -69,15 +69,15 @@
void set_extensions(const flutter::EncodableList& value_arg);
private:
- TypeGroup(flutter::EncodableMap map);
- flutter::EncodableMap ToEncodableMap() const;
+ TypeGroup(const flutter::EncodableList& list);
+ flutter::EncodableList ToEncodableList() const;
friend class FileSelectorApi;
friend class FileSelectorApiCodecSerializer;
std::string label_;
flutter::EncodableList extensions_;
};
-/* Generated class from Pigeon that represents data sent in messages. */
+// Generated class from Pigeon that represents data sent in messages.
class SelectionOptions {
public:
SelectionOptions();
@@ -91,8 +91,8 @@
void set_allowed_types(const flutter::EncodableList& value_arg);
private:
- SelectionOptions(flutter::EncodableMap map);
- flutter::EncodableMap ToEncodableMap() const;
+ SelectionOptions(const flutter::EncodableList& list);
+ flutter::EncodableList ToEncodableList() const;
friend class FileSelectorApi;
friend class FileSelectorApiCodecSerializer;
bool allow_multiple_;
@@ -118,13 +118,13 @@
uint8_t type, flutter::ByteStreamReader* stream) const override;
};
-/* Generated class from Pigeon that represents a handler of messages from
- * Flutter. */
+// Generated interface from Pigeon that represents a handler of messages from
+// Flutter.
class FileSelectorApi {
public:
FileSelectorApi(const FileSelectorApi&) = delete;
FileSelectorApi& operator=(const FileSelectorApi&) = delete;
- virtual ~FileSelectorApi(){};
+ virtual ~FileSelectorApi() {}
virtual ErrorOr<flutter::EncodableList> ShowOpenDialog(
const SelectionOptions& options, const std::string* initial_directory,
const std::string* confirm_button_text) = 0;
@@ -133,17 +133,17 @@
const std::string* suggested_name,
const std::string* confirm_button_text) = 0;
- /** The codec used by FileSelectorApi. */
+ // The codec used by FileSelectorApi.
static const flutter::StandardMessageCodec& GetCodec();
- /** Sets up an instance of `FileSelectorApi` to handle messages through the
- * `binary_messenger`. */
+ // Sets up an instance of `FileSelectorApi` to handle messages through the
+ // `binary_messenger`.
static void SetUp(flutter::BinaryMessenger* binary_messenger,
FileSelectorApi* api);
- static flutter::EncodableMap WrapError(std::string_view error_message);
- static flutter::EncodableMap WrapError(const FlutterError& error);
+ static flutter::EncodableValue WrapError(std::string_view error_message);
+ static flutter::EncodableValue WrapError(const FlutterError& error);
protected:
FileSelectorApi() = default;
};
} // namespace file_selector_windows
-#endif // PIGEON_MESSAGES_G_FILE_SELECTOR_WINDOWS_H_
+#endif // PIGEON_MESSAGES_G_H_