Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/file_selector/file_selector_windows/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]);
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -37,7 +37,7 @@ class TypeGroup {

String label;

List<String?> extensions;
List<String> extensions;

Object encode() {
return <Object?>[
Expand All @@ -50,7 +50,7 @@ class TypeGroup {
result as List<Object?>;
return TypeGroup(
label: result[0]! as String,
extensions: (result[1] as List<Object?>?)!.cast<String?>(),
extensions: (result[1] as List<Object?>?)!.cast<String>(),
);
}
}
Expand All @@ -59,14 +59,14 @@ class SelectionOptions {
SelectionOptions({
this.allowMultiple = false,
this.selectFolders = false,
this.allowedTypes = const <TypeGroup?>[],
this.allowedTypes = const <TypeGroup>[],
});

bool allowMultiple;

bool selectFolders;

List<TypeGroup?> allowedTypes;
List<TypeGroup> allowedTypes;

Object encode() {
return <Object?>[
Expand All @@ -81,7 +81,7 @@ class SelectionOptions {
return SelectionOptions(
allowMultiple: result[0]! as bool,
selectFolders: result[1]! as bool,
allowedTypes: (result[2] as List<Object?>?)!.cast<TypeGroup?>(),
allowedTypes: (result[2] as List<Object?>?)!.cast<TypeGroup>(),
);
}
}
Expand All @@ -96,7 +96,7 @@ class FileDialogResult {
/// The selected paths.
///
/// Empty if the dialog was canceled.
List<String?> paths;
List<String> paths;

/// The type group index (into the list provided in [SelectionOptions]) of
/// the group that was selected when the dialog was confirmed.
Expand All @@ -114,7 +114,7 @@ class FileDialogResult {
static FileDialogResult decode(Object result) {
result as List<Object?>;
return FileDialogResult(
paths: (result[0] as List<Object?>?)!.cast<String?>(),
paths: (result[0] as List<Object?>?)!.cast<String>(),
typeGroupIndex: result[1] as int?,
);
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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<Object?> pigeonChannelCodec = _PigeonCodec();

final String __pigeon_messageChannelSuffix;
final String pigeonVar_messageChannelSuffix;

Future<FileDialogResult> showOpenDialog(SelectionOptions options,
String? initialDirectory, String? confirmButtonText) async {
final String __pigeon_channelName =
'dev.flutter.pigeon.file_selector_windows.FileSelectorApi.showOpenDialog$__pigeon_messageChannelSuffix';
final BasicMessageChannel<Object?> __pigeon_channel =
final String pigeonVar_channelName =
'dev.flutter.pigeon.file_selector_windows.FileSelectorApi.showOpenDialog$pigeonVar_messageChannelSuffix';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
__pigeon_channelName,
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: __pigeon_binaryMessenger,
binaryMessenger: pigeonVar_binaryMessenger,
);
final List<Object?>? __pigeon_replyList = await __pigeon_channel
final List<Object?>? pigeonVar_replyList = await pigeonVar_channel
.send(<Object?>[options, initialDirectory, confirmButtonText])
as List<Object?>?;
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?)!;
}
}

Expand All @@ -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<Object?> __pigeon_channel =
final String pigeonVar_channelName =
'dev.flutter.pigeon.file_selector_windows.FileSelectorApi.showSaveDialog$pigeonVar_messageChannelSuffix';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
__pigeon_channelName,
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: __pigeon_binaryMessenger,
binaryMessenger: pigeonVar_binaryMessenger,
);
final List<Object?>? __pigeon_replyList = await __pigeon_channel
final List<Object?>? pigeonVar_replyList = await pigeonVar_channel
.send(<Object?>[
options,
initialDirectory,
suggestedName,
confirmButtonText
]) as List<Object?>?;
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?)!;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String?> extensions;
List<String> extensions;
}

class SelectionOptions {
SelectionOptions({
this.allowMultiple = false,
this.selectFolders = false,
this.allowedTypes = const <TypeGroup?>[],
this.allowedTypes = const <TypeGroup>[],
});
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<TypeGroup?> allowedTypes;
List<TypeGroup> allowedTypes;
}

/// The result from an open or save dialog.
Expand All @@ -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<String?> paths;
List<String> paths;

/// The type group index (into the list provided in [SelectionOptions]) of
/// the group that was selected when the dialog was confirmed.
Expand Down
4 changes: 2 additions & 2 deletions packages/file_selector/file_selector_windows/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,7 +27,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
mockito: 5.4.4
pigeon: ^21.0.0
pigeon: ^22.4.1

topics:
- files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void main() {
group('openFile', () {
setUp(() {
when(mockApi.showOpenDialog(any, any, any))
.thenReturn(FileDialogResult(paths: <String?>['foo']));
.thenReturn(FileDialogResult(paths: <String>['foo']));
});

test('simple call works', () async {
Expand Down Expand Up @@ -109,7 +109,7 @@ void main() {
group('openFiles', () {
setUp(() {
when(mockApi.showOpenDialog(any, any, any))
.thenReturn(FileDialogResult(paths: <String?>['foo', 'bar']));
.thenReturn(FileDialogResult(paths: <String>['foo', 'bar']));
});

test('simple call works', () async {
Expand Down Expand Up @@ -186,7 +186,7 @@ void main() {
group('getDirectoryPath', () {
setUp(() {
when(mockApi.showOpenDialog(any, any, any))
.thenReturn(FileDialogResult(paths: <String?>['foo']));
.thenReturn(FileDialogResult(paths: <String>['foo']));
});

test('simple call works', () async {
Expand Down Expand Up @@ -216,11 +216,11 @@ void main() {
group('getDirectoryPaths', () {
setUp(() {
when(mockApi.showOpenDialog(any, any, any))
.thenReturn(FileDialogResult(paths: <String?>['foo', 'bar']));
.thenReturn(FileDialogResult(paths: <String>['foo', 'bar']));
});

test('simple call works', () async {
final List<String?> paths = await plugin.getDirectoryPaths();
final List<String> paths = await plugin.getDirectoryPaths();

expect(paths[0], 'foo');
expect(paths[1], 'bar');
Expand All @@ -247,7 +247,7 @@ void main() {
group('getSaveLocation', () {
setUp(() {
when(mockApi.showSaveDialog(any, any, any, any))
.thenReturn(FileDialogResult(paths: <String?>['foo']));
.thenReturn(FileDialogResult(paths: <String>['foo']));
});

test('simple call works', () async {
Expand Down Expand Up @@ -291,7 +291,7 @@ void main() {

test('returns the selected type group correctly', () async {
when(mockApi.showSaveDialog(any, any, any, any)).thenReturn(
FileDialogResult(paths: <String?>['foo'], typeGroupIndex: 1));
FileDialogResult(paths: <String>['foo'], typeGroupIndex: 1));
const XTypeGroup group = XTypeGroup(
label: 'text',
extensions: <String>['txt'],
Expand Down Expand Up @@ -359,7 +359,7 @@ void main() {
group('getSavePath (deprecated)', () {
setUp(() {
when(mockApi.showSaveDialog(any, any, any, any))
.thenReturn(FileDialogResult(paths: <String?>['foo']));
.thenReturn(FileDialogResult(paths: <String>['foo']));
});

test('simple call works', () async {
Expand Down
Loading