1
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
2
// Use of this source code is governed by a BSD-style license that can be
3
3
// found in the LICENSE file.
4
- // Autogenerated from Pigeon (v22.6.1 ), do not edit directly.
4
+ // Autogenerated from Pigeon (v22.7.2 ), do not edit directly.
5
5
// See also: https://pub.dev/packages/pigeon
6
6
// 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
7
7
@@ -29,6 +29,45 @@ List<Object?> wrapResponse(
29
29
return < Object ? > [error.code, error.message, error.details];
30
30
}
31
31
32
+ /// Possible error conditions for [ImagePickerApi] calls.
33
+ enum ImagePickerError {
34
+ /// The current macOS version doesn't support [PHPickerViewController] (https://developer.apple.com/documentation/photosui/phpickerviewcontroller)
35
+ /// which is supported on macOS 13+.
36
+ phpickerUnsupported,
37
+
38
+ /// Could not show the picker due to the missing window.
39
+ windowNotFound,
40
+
41
+ /// When a `PHPickerResult` can't load `NSImage` . This error should not be reached
42
+ /// as the filter in the `PHPickerConfiguration` is set to accept only images.
43
+ invalidImageSelection,
44
+
45
+ /// When a `PHPickerResult` is not a video. This error should not be reached
46
+ /// as the filter in the `PHPickerConfiguration` is set to accept only videos.
47
+ invalidVideoSelection,
48
+
49
+ /// Could not load the image object as `NSImage` .
50
+ imageLoadFailed,
51
+
52
+ /// Could not load the video data representation.
53
+ videoLoadFailed,
54
+
55
+ /// The image tiff representation could not be loaded from the `NSImage` .
56
+ imageConversionFailed,
57
+
58
+ /// The loaded `Data` from the `NSImage` could not be written as a file.
59
+ imageSaveFailed,
60
+
61
+ /// The image could not be compressed or the `NSImage` could not be created
62
+ /// from the compressed `Data` .
63
+ imageCompressionFailed,
64
+
65
+ /// The multi-video selection is not supported as it's not supported in
66
+ /// the app-facing package (`pickVideos` is missing).
67
+ /// The multi-video selection is supported when using `pickMedia` instead.
68
+ multiVideoSelectionUnsupported,
69
+ }
70
+
32
71
/// The common options between [ImageSelectionOptions] , [VideoSelectionOptions]
33
72
/// and [MediaSelectionOptions] .
34
73
class GeneralOptions {
@@ -132,24 +171,85 @@ class MediaSelectionOptions {
132
171
}
133
172
}
134
173
174
+ sealed class ImagePickerResult {}
175
+
176
+ class ImagePickerSuccessResult extends ImagePickerResult {
177
+ ImagePickerSuccessResult ({
178
+ required this .filePaths,
179
+ });
180
+
181
+ /// The temporary file paths as a result of picking the images and/or videos.
182
+ List <String > filePaths;
183
+
184
+ Object encode () {
185
+ return < Object ? > [
186
+ filePaths,
187
+ ];
188
+ }
189
+
190
+ static ImagePickerSuccessResult decode (Object result) {
191
+ result as List <Object ?>;
192
+ return ImagePickerSuccessResult (
193
+ filePaths: (result[0 ] as List <Object ?>? )! .cast <String >(),
194
+ );
195
+ }
196
+ }
197
+
198
+ class ImagePickerErrorResult extends ImagePickerResult {
199
+ ImagePickerErrorResult ({
200
+ required this .error,
201
+ this .platformErrorMessage,
202
+ });
203
+
204
+ /// Potential error conditions for [ImagePickerApi] calls.
205
+ ImagePickerError error;
206
+
207
+ /// Additional error message from the platform side.
208
+ String ? platformErrorMessage;
209
+
210
+ Object encode () {
211
+ return < Object ? > [
212
+ error,
213
+ platformErrorMessage,
214
+ ];
215
+ }
216
+
217
+ static ImagePickerErrorResult decode (Object result) {
218
+ result as List <Object ?>;
219
+ return ImagePickerErrorResult (
220
+ error: result[0 ]! as ImagePickerError ,
221
+ platformErrorMessage: result[1 ] as String ? ,
222
+ );
223
+ }
224
+ }
225
+
135
226
class _PigeonCodec extends StandardMessageCodec {
136
227
const _PigeonCodec ();
137
228
@override
138
229
void writeValue (WriteBuffer buffer, Object ? value) {
139
230
if (value is int ) {
140
231
buffer.putUint8 (4 );
141
232
buffer.putInt64 (value);
142
- } else if (value is GeneralOptions ) {
233
+ } else if (value is ImagePickerError ) {
143
234
buffer.putUint8 (129 );
235
+ writeValue (buffer, value.index);
236
+ } else if (value is GeneralOptions ) {
237
+ buffer.putUint8 (130 );
144
238
writeValue (buffer, value.encode ());
145
239
} else if (value is MaxSize ) {
146
- buffer.putUint8 (130 );
240
+ buffer.putUint8 (131 );
147
241
writeValue (buffer, value.encode ());
148
242
} else if (value is ImageSelectionOptions ) {
149
- buffer.putUint8 (131 );
243
+ buffer.putUint8 (132 );
150
244
writeValue (buffer, value.encode ());
151
245
} else if (value is MediaSelectionOptions ) {
152
- buffer.putUint8 (132 );
246
+ buffer.putUint8 (133 );
247
+ writeValue (buffer, value.encode ());
248
+ } else if (value is ImagePickerSuccessResult ) {
249
+ buffer.putUint8 (134 );
250
+ writeValue (buffer, value.encode ());
251
+ } else if (value is ImagePickerErrorResult ) {
252
+ buffer.putUint8 (135 );
153
253
writeValue (buffer, value.encode ());
154
254
} else {
155
255
super .writeValue (buffer, value);
@@ -160,13 +260,20 @@ class _PigeonCodec extends StandardMessageCodec {
160
260
Object ? readValueOfType (int type, ReadBuffer buffer) {
161
261
switch (type) {
162
262
case 129 :
163
- return GeneralOptions .decode (readValue (buffer)! );
263
+ final int ? value = readValue (buffer) as int ? ;
264
+ return value == null ? null : ImagePickerError .values[value];
164
265
case 130 :
165
- return MaxSize .decode (readValue (buffer)! );
266
+ return GeneralOptions .decode (readValue (buffer)! );
166
267
case 131 :
167
- return ImageSelectionOptions .decode (readValue (buffer)! );
268
+ return MaxSize .decode (readValue (buffer)! );
168
269
case 132 :
270
+ return ImageSelectionOptions .decode (readValue (buffer)! );
271
+ case 133 :
169
272
return MediaSelectionOptions .decode (readValue (buffer)! );
273
+ case 134 :
274
+ return ImagePickerSuccessResult .decode (readValue (buffer)! );
275
+ case 135 :
276
+ return ImagePickerErrorResult .decode (readValue (buffer)! );
170
277
default :
171
278
return super .readValueOfType (type, buffer);
172
279
}
@@ -188,6 +295,8 @@ class ImagePickerApi {
188
295
189
296
final String pigeonVar_messageChannelSuffix;
190
297
298
+ /// Returns whether [PHPickerViewController] (https://developer.apple.com/documentation/photosui/phpickerviewcontroller)
299
+ /// is supported on the current macOS version.
191
300
Future <bool > supportsPHPicker () async {
192
301
final String pigeonVar_channelName =
193
302
'dev.flutter.pigeon.image_picker_macos.ImagePickerApi.supportsPHPicker$pigeonVar_messageChannelSuffix ' ;
@@ -217,7 +326,7 @@ class ImagePickerApi {
217
326
}
218
327
}
219
328
220
- Future <List < String > > pickImages (
329
+ Future <ImagePickerResult > pickImages (
221
330
ImageSelectionOptions options, GeneralOptions generalOptions) async {
222
331
final String pigeonVar_channelName =
223
332
'dev.flutter.pigeon.image_picker_macos.ImagePickerApi.pickImages$pigeonVar_messageChannelSuffix ' ;
@@ -243,12 +352,12 @@ class ImagePickerApi {
243
352
message: 'Host platform returned null value for non-null return value.' ,
244
353
);
245
354
} else {
246
- return (pigeonVar_replyList[0 ] as List < Object ?> ? ) ! . cast < String >() ;
355
+ return (pigeonVar_replyList[0 ] as ImagePickerResult ? ) ! ;
247
356
}
248
357
}
249
358
250
359
/// Currently, multi-video selection is unimplemented.
251
- Future <List < String > > pickVideos (GeneralOptions generalOptions) async {
360
+ Future <ImagePickerResult > pickVideos (GeneralOptions generalOptions) async {
252
361
final String pigeonVar_channelName =
253
362
'dev.flutter.pigeon.image_picker_macos.ImagePickerApi.pickVideos$pigeonVar_messageChannelSuffix ' ;
254
363
final BasicMessageChannel <Object ?> pigeonVar_channel =
@@ -273,11 +382,11 @@ class ImagePickerApi {
273
382
message: 'Host platform returned null value for non-null return value.' ,
274
383
);
275
384
} else {
276
- return (pigeonVar_replyList[0 ] as List < Object ?> ? ) ! . cast < String >() ;
385
+ return (pigeonVar_replyList[0 ] as ImagePickerResult ? ) ! ;
277
386
}
278
387
}
279
388
280
- Future <List < String > > pickMedia (
389
+ Future <ImagePickerResult > pickMedia (
281
390
MediaSelectionOptions options, GeneralOptions generalOptions) async {
282
391
final String pigeonVar_channelName =
283
392
'dev.flutter.pigeon.image_picker_macos.ImagePickerApi.pickMedia$pigeonVar_messageChannelSuffix ' ;
@@ -303,7 +412,7 @@ class ImagePickerApi {
303
412
message: 'Host platform returned null value for non-null return value.' ,
304
413
);
305
414
} else {
306
- return (pigeonVar_replyList[0 ] as List < Object ?> ? ) ! . cast < String >() ;
415
+ return (pigeonVar_replyList[0 ] as ImagePickerResult ? ) ! ;
307
416
}
308
417
}
309
418
}
0 commit comments