diff --git a/packages/file_selector/file_selector_windows/CHANGELOG.md b/packages/file_selector/file_selector_windows/CHANGELOG.md index b321feacbc6..77b5c11c475 100644 --- a/packages/file_selector/file_selector_windows/CHANGELOG.md +++ b/packages/file_selector/file_selector_windows/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 0.9.3+3 +* Updates Pigeon for non-nullable collection type support. * Updates minimum supported SDK version to Flutter 3.19/Dart 3.3. ## 0.9.3+2 diff --git a/packages/file_selector/file_selector_windows/lib/file_selector_windows.dart b/packages/file_selector/file_selector_windows/lib/file_selector_windows.dart index 96f53b6ca0f..150e165fd21 100644 --- a/packages/file_selector/file_selector_windows/lib/file_selector_windows.dart +++ b/packages/file_selector/file_selector_windows/lib/file_selector_windows.dart @@ -27,7 +27,7 @@ class FileSelectorWindows extends FileSelectorPlatform { ), initialDirectory, confirmButtonText); - return result.paths.isEmpty ? null : XFile(result.paths.first!); + return result.paths.isEmpty ? null : XFile(result.paths.first); } @override @@ -78,7 +78,7 @@ class FileSelectorWindows extends FileSelectorPlatform { final int? groupIndex = result.typeGroupIndex; return result.paths.isEmpty ? null - : FileSaveLocation(result.paths.first!, + : FileSaveLocation(result.paths.first, activeFilter: groupIndex == null ? null : acceptedTypeGroups?[groupIndex]); } @@ -95,7 +95,7 @@ class FileSelectorWindows extends FileSelectorPlatform { ), initialDirectory, confirmButtonText); - return result.paths.isEmpty ? null : result.paths.first!; + return result.paths.isEmpty ? null : result.paths.first; } @override 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 12f57b1969e..6ec5eee613c 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,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 (v21.0.0), do not edit directly. +// Autogenerated from Pigeon (v22.4.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, no_leading_underscores_for_local_identifiers @@ -37,7 +37,7 @@ class TypeGroup { String label; - List extensions; + List extensions; Object encode() { return [ @@ -50,7 +50,7 @@ class TypeGroup { result as List; return TypeGroup( label: result[0]! as String, - extensions: (result[1] as List?)!.cast(), + extensions: (result[1] as List?)!.cast(), ); } } @@ -59,14 +59,14 @@ class SelectionOptions { SelectionOptions({ this.allowMultiple = false, this.selectFolders = false, - this.allowedTypes = const [], + this.allowedTypes = const [], }); bool allowMultiple; bool selectFolders; - List allowedTypes; + List allowedTypes; Object encode() { return [ @@ -81,7 +81,7 @@ class SelectionOptions { return SelectionOptions( allowMultiple: result[0]! as bool, selectFolders: result[1]! as bool, - allowedTypes: (result[2] as List?)!.cast(), + allowedTypes: (result[2] as List?)!.cast(), ); } } @@ -96,7 +96,7 @@ class FileDialogResult { /// The selected paths. /// /// Empty if the dialog was canceled. - List paths; + List paths; /// The type group index (into the list provided in [SelectionOptions]) of /// the group that was selected when the dialog was confirmed. @@ -114,7 +114,7 @@ class FileDialogResult { static FileDialogResult decode(Object result) { result as List; return FileDialogResult( - paths: (result[0] as List?)!.cast(), + paths: (result[0] as List?)!.cast(), typeGroupIndex: result[1] as int?, ); } @@ -124,7 +124,10 @@ class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override void writeValue(WriteBuffer buffer, Object? value) { - if (value is TypeGroup) { + if (value is int) { + buffer.putUint8(4); + buffer.putInt64(value); + } else if (value is TypeGroup) { buffer.putUint8(129); writeValue(buffer, value.encode()); } else if (value is SelectionOptions) { @@ -159,43 +162,43 @@ class FileSelectorApi { /// BinaryMessenger will be used which routes to the host platform. FileSelectorApi( {BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) - : __pigeon_binaryMessenger = binaryMessenger, - __pigeon_messageChannelSuffix = + : pigeonVar_binaryMessenger = binaryMessenger, + pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; - final BinaryMessenger? __pigeon_binaryMessenger; + final BinaryMessenger? pigeonVar_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); - final String __pigeon_messageChannelSuffix; + final String pigeonVar_messageChannelSuffix; Future showOpenDialog(SelectionOptions options, String? initialDirectory, String? confirmButtonText) async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.file_selector_windows.FileSelectorApi.showOpenDialog$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = + final String pigeonVar_channelName = + 'dev.flutter.pigeon.file_selector_windows.FileSelectorApi.showOpenDialog$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([options, initialDirectory, confirmButtonText]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as FileDialogResult?)!; + return (pigeonVar_replyList[0] as FileDialogResult?)!; } } @@ -204,36 +207,36 @@ class FileSelectorApi { String? initialDirectory, String? suggestedName, String? confirmButtonText) async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.file_selector_windows.FileSelectorApi.showSaveDialog$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = + final String pigeonVar_channelName = + 'dev.flutter.pigeon.file_selector_windows.FileSelectorApi.showSaveDialog$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([ options, initialDirectory, suggestedName, confirmButtonText ]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as FileDialogResult?)!; + return (pigeonVar_replyList[0] as FileDialogResult?)!; } } } diff --git a/packages/file_selector/file_selector_windows/pigeons/messages.dart b/packages/file_selector/file_selector_windows/pigeons/messages.dart index 8f82aec0b83..75ba308dc14 100644 --- a/packages/file_selector/file_selector_windows/pigeons/messages.dart +++ b/packages/file_selector/file_selector_windows/pigeons/messages.dart @@ -16,25 +16,18 @@ class TypeGroup { TypeGroup(this.label, {required this.extensions}); String label; - // TODO(stuartmorgan): Make the generic type non-nullable once supported. - // https://github.com/flutter/flutter/issues/97848 - // The C++ code treats all of it as non-nullable. - List extensions; + List extensions; } class SelectionOptions { SelectionOptions({ this.allowMultiple = false, this.selectFolders = false, - this.allowedTypes = const [], + this.allowedTypes = const [], }); bool allowMultiple; bool selectFolders; - - // TODO(stuartmorgan): Make the generic type non-nullable once supported. - // https://github.com/flutter/flutter/issues/97848 - // The C++ code treats the values as non-nullable. - List allowedTypes; + List allowedTypes; } /// The result from an open or save dialog. @@ -44,10 +37,7 @@ class FileDialogResult { /// The selected paths. /// /// Empty if the dialog was canceled. - // TODO(stuartmorgan): Make the generic type non-nullable once supported. - // https://github.com/flutter/flutter/issues/97848 - // The Dart code treats the values as non-nullable. - List paths; + List paths; /// The type group index (into the list provided in [SelectionOptions]) of /// the group that was selected when the dialog was confirmed. diff --git a/packages/file_selector/file_selector_windows/pubspec.yaml b/packages/file_selector/file_selector_windows/pubspec.yaml index 26c111c40d8..4d57b6bbe67 100644 --- a/packages/file_selector/file_selector_windows/pubspec.yaml +++ b/packages/file_selector/file_selector_windows/pubspec.yaml @@ -2,7 +2,7 @@ name: file_selector_windows 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.3+2 +version: 0.9.3+3 environment: sdk: ^3.3.0 @@ -27,7 +27,7 @@ dev_dependencies: flutter_test: sdk: flutter mockito: 5.4.4 - pigeon: ^21.0.0 + pigeon: ^22.4.1 topics: - files diff --git a/packages/file_selector/file_selector_windows/test/file_selector_windows_test.dart b/packages/file_selector/file_selector_windows/test/file_selector_windows_test.dart index 4d67562f03c..3a4510672f2 100644 --- a/packages/file_selector/file_selector_windows/test/file_selector_windows_test.dart +++ b/packages/file_selector/file_selector_windows/test/file_selector_windows_test.dart @@ -33,7 +33,7 @@ void main() { group('openFile', () { setUp(() { when(mockApi.showOpenDialog(any, any, any)) - .thenReturn(FileDialogResult(paths: ['foo'])); + .thenReturn(FileDialogResult(paths: ['foo'])); }); test('simple call works', () async { @@ -109,7 +109,7 @@ void main() { group('openFiles', () { setUp(() { when(mockApi.showOpenDialog(any, any, any)) - .thenReturn(FileDialogResult(paths: ['foo', 'bar'])); + .thenReturn(FileDialogResult(paths: ['foo', 'bar'])); }); test('simple call works', () async { @@ -186,7 +186,7 @@ void main() { group('getDirectoryPath', () { setUp(() { when(mockApi.showOpenDialog(any, any, any)) - .thenReturn(FileDialogResult(paths: ['foo'])); + .thenReturn(FileDialogResult(paths: ['foo'])); }); test('simple call works', () async { @@ -216,11 +216,11 @@ void main() { group('getDirectoryPaths', () { setUp(() { when(mockApi.showOpenDialog(any, any, any)) - .thenReturn(FileDialogResult(paths: ['foo', 'bar'])); + .thenReturn(FileDialogResult(paths: ['foo', 'bar'])); }); test('simple call works', () async { - final List paths = await plugin.getDirectoryPaths(); + final List paths = await plugin.getDirectoryPaths(); expect(paths[0], 'foo'); expect(paths[1], 'bar'); @@ -247,7 +247,7 @@ void main() { group('getSaveLocation', () { setUp(() { when(mockApi.showSaveDialog(any, any, any, any)) - .thenReturn(FileDialogResult(paths: ['foo'])); + .thenReturn(FileDialogResult(paths: ['foo'])); }); test('simple call works', () async { @@ -291,7 +291,7 @@ void main() { test('returns the selected type group correctly', () async { when(mockApi.showSaveDialog(any, any, any, any)).thenReturn( - FileDialogResult(paths: ['foo'], typeGroupIndex: 1)); + FileDialogResult(paths: ['foo'], typeGroupIndex: 1)); const XTypeGroup group = XTypeGroup( label: 'text', extensions: ['txt'], @@ -359,7 +359,7 @@ void main() { group('getSavePath (deprecated)', () { setUp(() { when(mockApi.showSaveDialog(any, any, any, any)) - .thenReturn(FileDialogResult(paths: ['foo'])); + .thenReturn(FileDialogResult(paths: ['foo'])); }); test('simple call works', () async { 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 2f9cabdef2d..018f425bf1d 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,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 (v21.0.0), do not edit directly. +// Autogenerated from Pigeon (v22.4.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, no_leading_underscores_for_local_identifiers // ignore_for_file: avoid_relative_lib_imports @@ -17,7 +17,10 @@ class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override void writeValue(WriteBuffer buffer, Object? value) { - if (value is TypeGroup) { + if (value is int) { + buffer.putUint8(4); + buffer.putInt64(value); + } else if (value is TypeGroup) { buffer.putUint8(129); writeValue(buffer, value.encode()); } else if (value is SelectionOptions) { @@ -68,17 +71,18 @@ abstract class TestFileSelectorApi { messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.file_selector_windows.FileSelectorApi.showOpenDialog$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, null); + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, + .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.file_selector_windows.FileSelectorApi.showOpenDialog was null.'); @@ -102,17 +106,18 @@ abstract class TestFileSelectorApi { } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.file_selector_windows.FileSelectorApi.showSaveDialog$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, null); + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, + .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.file_selector_windows.FileSelectorApi.showSaveDialog was null.'); 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 fc145c6740f..f831e50ead3 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 (v21.0.0), do not edit directly. +// Autogenerated from Pigeon (v22.4.1), do not edit directly. // See also: https://pub.dev/packages/pigeon #undef _HAS_EXCEPTIONS @@ -149,31 +149,34 @@ FileDialogResult FileDialogResult::FromEncodableList( FileDialogResult decoded(std::get(list[0])); auto& encodable_type_group_index = list[1]; if (!encodable_type_group_index.IsNull()) { - decoded.set_type_group_index(encodable_type_group_index.LongValue()); + decoded.set_type_group_index(std::get(encodable_type_group_index)); } return decoded; } -PigeonCodecSerializer::PigeonCodecSerializer() {} +PigeonInternalCodecSerializer::PigeonInternalCodecSerializer() {} -EncodableValue PigeonCodecSerializer::ReadValueOfType( +EncodableValue PigeonInternalCodecSerializer::ReadValueOfType( uint8_t type, flutter::ByteStreamReader* stream) const { switch (type) { - case 129: + case 129: { return CustomEncodableValue(TypeGroup::FromEncodableList( std::get(ReadValue(stream)))); - case 130: + } + case 130: { return CustomEncodableValue(SelectionOptions::FromEncodableList( std::get(ReadValue(stream)))); - case 131: + } + case 131: { return CustomEncodableValue(FileDialogResult::FromEncodableList( std::get(ReadValue(stream)))); + } default: return flutter::StandardCodecSerializer::ReadValueOfType(type, stream); } } -void PigeonCodecSerializer::WriteValue( +void PigeonInternalCodecSerializer::WriteValue( const EncodableValue& value, flutter::ByteStreamWriter* stream) const { if (const CustomEncodableValue* custom_value = std::get_if(&value)) { @@ -207,7 +210,7 @@ void PigeonCodecSerializer::WriteValue( /// The codec used by FileSelectorApi. const flutter::StandardMessageCodec& FileSelectorApi::GetCodec() { return flutter::StandardMessageCodec::GetInstance( - &PigeonCodecSerializer::GetInstance()); + &PigeonInternalCodecSerializer::GetInstance()); } // Sets up an instance of `FileSelectorApi` to handle messages through the 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 43f67148050..edd0865d78c 100644 --- a/packages/file_selector/file_selector_windows/windows/messages.g.h +++ b/packages/file_selector/file_selector_windows/windows/messages.g.h @@ -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 (v21.0.0), do not edit directly. +// Autogenerated from Pigeon (v22.4.1), do not edit directly. // See also: https://pub.dev/packages/pigeon #ifndef PIGEON_MESSAGES_G_H_ @@ -75,7 +75,7 @@ class TypeGroup { static TypeGroup FromEncodableList(const flutter::EncodableList& list); flutter::EncodableList ToEncodableList() const; friend class FileSelectorApi; - friend class PigeonCodecSerializer; + friend class PigeonInternalCodecSerializer; std::string label_; flutter::EncodableList extensions_; }; @@ -100,7 +100,7 @@ class SelectionOptions { static SelectionOptions FromEncodableList(const flutter::EncodableList& list); flutter::EncodableList ToEncodableList() const; friend class FileSelectorApi; - friend class PigeonCodecSerializer; + friend class PigeonInternalCodecSerializer; bool allow_multiple_; bool select_folders_; flutter::EncodableList allowed_types_; @@ -136,16 +136,16 @@ class FileDialogResult { static FileDialogResult FromEncodableList(const flutter::EncodableList& list); flutter::EncodableList ToEncodableList() const; friend class FileSelectorApi; - friend class PigeonCodecSerializer; + friend class PigeonInternalCodecSerializer; flutter::EncodableList paths_; std::optional type_group_index_; }; -class PigeonCodecSerializer : public flutter::StandardCodecSerializer { +class PigeonInternalCodecSerializer : public flutter::StandardCodecSerializer { public: - PigeonCodecSerializer(); - inline static PigeonCodecSerializer& GetInstance() { - static PigeonCodecSerializer sInstance; + PigeonInternalCodecSerializer(); + inline static PigeonInternalCodecSerializer& GetInstance() { + static PigeonInternalCodecSerializer sInstance; return sInstance; }