@@ -15,7 +15,8 @@ PlatformException _createConnectionError(String channelName) {
15
15
);
16
16
}
17
17
18
- List <Object ?> wrapResponse ({Object ? result, PlatformException ? error, bool empty = false }) {
18
+ List <Object ?> wrapResponse (
19
+ {Object ? result, PlatformException ? error, bool empty = false }) {
19
20
if (empty) {
20
21
return < Object ? > [];
21
22
}
@@ -30,25 +31,34 @@ enum ImagePickerError {
30
31
/// The current macOS version doesn't support [PHPickerViewController] (https://developer.apple.com/documentation/photosui/phpickerviewcontroller)
31
32
/// which is supported on macOS 13+.
32
33
phpickerUnsupported,
34
+
33
35
/// Could not show the picker due to the missing window.
34
36
windowNotFound,
37
+
35
38
/// When a `PHPickerResult` can't load `NSImage` . This error should not be reached
36
39
/// as the filter in the `PHPickerConfiguration` is set to accept only images.
37
40
invalidImageSelection,
41
+
38
42
/// When a `PHPickerResult` is not a video. This error should not be reached
39
43
/// as the filter in the `PHPickerConfiguration` is set to accept only videos.
40
44
invalidVideoSelection,
45
+
41
46
/// Could not load the image object as `NSImage` .
42
47
imageLoadFailed,
48
+
43
49
/// Could not load the video data representation.
44
50
videoLoadFailed,
51
+
45
52
/// The image tiff representation could not be loaded from the `NSImage` .
46
53
imageConversionFailed,
54
+
47
55
/// The loaded `Data` from the `NSImage` could not be written as a file.
48
56
imageSaveFailed,
57
+
49
58
/// The image could not be compressed or the `NSImage` could not be created
50
59
/// from the compressed `Data` .
51
60
imageCompressionFailed,
61
+
52
62
/// The multi-video selection is not supported as it's not supported in
53
63
/// the app-facing package (`pickVideos` is missing).
54
64
/// The multi-video selection is supported when using `pickMedia` instead.
@@ -158,8 +168,7 @@ class MediaSelectionOptions {
158
168
}
159
169
}
160
170
161
- sealed class ImagePickerResult {
162
- }
171
+ sealed class ImagePickerResult {}
163
172
164
173
class ImagePickerSuccessResult extends ImagePickerResult {
165
174
ImagePickerSuccessResult ({
@@ -211,33 +220,32 @@ class ImagePickerErrorResult extends ImagePickerResult {
211
220
}
212
221
}
213
222
214
-
215
223
class _PigeonCodec extends StandardMessageCodec {
216
224
const _PigeonCodec ();
217
225
@override
218
226
void writeValue (WriteBuffer buffer, Object ? value) {
219
227
if (value is int ) {
220
228
buffer.putUint8 (4 );
221
229
buffer.putInt64 (value);
222
- } else if (value is ImagePickerError ) {
230
+ } else if (value is ImagePickerError ) {
223
231
buffer.putUint8 (129 );
224
232
writeValue (buffer, value.index);
225
- } else if (value is GeneralOptions ) {
233
+ } else if (value is GeneralOptions ) {
226
234
buffer.putUint8 (130 );
227
235
writeValue (buffer, value.encode ());
228
- } else if (value is MaxSize ) {
236
+ } else if (value is MaxSize ) {
229
237
buffer.putUint8 (131 );
230
238
writeValue (buffer, value.encode ());
231
- } else if (value is ImageSelectionOptions ) {
239
+ } else if (value is ImageSelectionOptions ) {
232
240
buffer.putUint8 (132 );
233
241
writeValue (buffer, value.encode ());
234
- } else if (value is MediaSelectionOptions ) {
242
+ } else if (value is MediaSelectionOptions ) {
235
243
buffer.putUint8 (133 );
236
244
writeValue (buffer, value.encode ());
237
- } else if (value is ImagePickerSuccessResult ) {
245
+ } else if (value is ImagePickerSuccessResult ) {
238
246
buffer.putUint8 (134 );
239
247
writeValue (buffer, value.encode ());
240
- } else if (value is ImagePickerErrorResult ) {
248
+ } else if (value is ImagePickerErrorResult ) {
241
249
buffer.putUint8 (135 );
242
250
writeValue (buffer, value.encode ());
243
251
} else {
@@ -248,20 +256,20 @@ class _PigeonCodec extends StandardMessageCodec {
248
256
@override
249
257
Object ? readValueOfType (int type, ReadBuffer buffer) {
250
258
switch (type) {
251
- case 129 :
259
+ case 129 :
252
260
final int ? value = readValue (buffer) as int ? ;
253
261
return value == null ? null : ImagePickerError .values[value];
254
- case 130 :
262
+ case 130 :
255
263
return GeneralOptions .decode (readValue (buffer)! );
256
- case 131 :
264
+ case 131 :
257
265
return MaxSize .decode (readValue (buffer)! );
258
- case 132 :
266
+ case 132 :
259
267
return ImageSelectionOptions .decode (readValue (buffer)! );
260
- case 133 :
268
+ case 133 :
261
269
return MediaSelectionOptions .decode (readValue (buffer)! );
262
- case 134 :
270
+ case 134 :
263
271
return ImagePickerSuccessResult .decode (readValue (buffer)! );
264
- case 135 :
272
+ case 135 :
265
273
return ImagePickerErrorResult .decode (readValue (buffer)! );
266
274
default :
267
275
return super .readValueOfType (type, buffer);
@@ -273,9 +281,11 @@ class ImagePickerApi {
273
281
/// Constructor for [ImagePickerApi] . The [binaryMessenger] named argument is
274
282
/// available for dependency injection. If it is left null, the default
275
283
/// BinaryMessenger will be used which routes to the host platform.
276
- ImagePickerApi ({BinaryMessenger ? binaryMessenger, String messageChannelSuffix = '' })
284
+ ImagePickerApi (
285
+ {BinaryMessenger ? binaryMessenger, String messageChannelSuffix = '' })
277
286
: pigeonVar_binaryMessenger = binaryMessenger,
278
- pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix ' : '' ;
287
+ pigeonVar_messageChannelSuffix =
288
+ messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix ' : '' ;
279
289
final BinaryMessenger ? pigeonVar_binaryMessenger;
280
290
281
291
static const MessageCodec <Object ?> pigeonChannelCodec = _PigeonCodec ();
@@ -285,8 +295,10 @@ class ImagePickerApi {
285
295
/// Returns whether [PHPickerViewController] (https://developer.apple.com/documentation/photosui/phpickerviewcontroller)
286
296
/// is supported on the current macOS version.
287
297
Future <bool > supportsPHPicker () async {
288
- final String pigeonVar_channelName = 'dev.flutter.pigeon.native_image_picker_macos.ImagePickerApi.supportsPHPicker$pigeonVar_messageChannelSuffix ' ;
289
- final BasicMessageChannel <Object ?> pigeonVar_channel = BasicMessageChannel <Object ?>(
298
+ final String pigeonVar_channelName =
299
+ 'dev.flutter.pigeon.native_image_picker_macos.ImagePickerApi.supportsPHPicker$pigeonVar_messageChannelSuffix ' ;
300
+ final BasicMessageChannel <Object ?> pigeonVar_channel =
301
+ BasicMessageChannel <Object ?>(
290
302
pigeonVar_channelName,
291
303
pigeonChannelCodec,
292
304
binaryMessenger: pigeonVar_binaryMessenger,
@@ -311,15 +323,18 @@ class ImagePickerApi {
311
323
}
312
324
}
313
325
314
- Future <ImagePickerResult > pickImages (ImageSelectionOptions options, GeneralOptions generalOptions) async {
315
- final String pigeonVar_channelName = 'dev.flutter.pigeon.native_image_picker_macos.ImagePickerApi.pickImages$pigeonVar_messageChannelSuffix ' ;
316
- final BasicMessageChannel <Object ?> pigeonVar_channel = BasicMessageChannel <Object ?>(
326
+ Future <ImagePickerResult > pickImages (
327
+ ImageSelectionOptions options, GeneralOptions generalOptions) async {
328
+ final String pigeonVar_channelName =
329
+ 'dev.flutter.pigeon.native_image_picker_macos.ImagePickerApi.pickImages$pigeonVar_messageChannelSuffix ' ;
330
+ final BasicMessageChannel <Object ?> pigeonVar_channel =
331
+ BasicMessageChannel <Object ?>(
317
332
pigeonVar_channelName,
318
333
pigeonChannelCodec,
319
334
binaryMessenger: pigeonVar_binaryMessenger,
320
335
);
321
- final List <Object ?>? pigeonVar_replyList =
322
- await pigeonVar_channel .send (< Object ? > [options, generalOptions]) as List <Object ?>? ;
336
+ final List <Object ?>? pigeonVar_replyList = await pigeonVar_channel
337
+ .send (< Object ? > [options, generalOptions]) as List <Object ?>? ;
323
338
if (pigeonVar_replyList == null ) {
324
339
throw _createConnectionError (pigeonVar_channelName);
325
340
} else if (pigeonVar_replyList.length > 1 ) {
@@ -339,14 +354,16 @@ class ImagePickerApi {
339
354
}
340
355
341
356
Future <ImagePickerResult > pickVideos (GeneralOptions generalOptions) async {
342
- final String pigeonVar_channelName = 'dev.flutter.pigeon.native_image_picker_macos.ImagePickerApi.pickVideos$pigeonVar_messageChannelSuffix ' ;
343
- final BasicMessageChannel <Object ?> pigeonVar_channel = BasicMessageChannel <Object ?>(
357
+ final String pigeonVar_channelName =
358
+ 'dev.flutter.pigeon.native_image_picker_macos.ImagePickerApi.pickVideos$pigeonVar_messageChannelSuffix ' ;
359
+ final BasicMessageChannel <Object ?> pigeonVar_channel =
360
+ BasicMessageChannel <Object ?>(
344
361
pigeonVar_channelName,
345
362
pigeonChannelCodec,
346
363
binaryMessenger: pigeonVar_binaryMessenger,
347
364
);
348
- final List <Object ?>? pigeonVar_replyList =
349
- await pigeonVar_channel .send (< Object ? > [generalOptions]) as List <Object ?>? ;
365
+ final List <Object ?>? pigeonVar_replyList = await pigeonVar_channel
366
+ .send (< Object ? > [generalOptions]) as List <Object ?>? ;
350
367
if (pigeonVar_replyList == null ) {
351
368
throw _createConnectionError (pigeonVar_channelName);
352
369
} else if (pigeonVar_replyList.length > 1 ) {
@@ -365,15 +382,18 @@ class ImagePickerApi {
365
382
}
366
383
}
367
384
368
- Future <ImagePickerResult > pickMedia (MediaSelectionOptions options, GeneralOptions generalOptions) async {
369
- final String pigeonVar_channelName = 'dev.flutter.pigeon.native_image_picker_macos.ImagePickerApi.pickMedia$pigeonVar_messageChannelSuffix ' ;
370
- final BasicMessageChannel <Object ?> pigeonVar_channel = BasicMessageChannel <Object ?>(
385
+ Future <ImagePickerResult > pickMedia (
386
+ MediaSelectionOptions options, GeneralOptions generalOptions) async {
387
+ final String pigeonVar_channelName =
388
+ 'dev.flutter.pigeon.native_image_picker_macos.ImagePickerApi.pickMedia$pigeonVar_messageChannelSuffix ' ;
389
+ final BasicMessageChannel <Object ?> pigeonVar_channel =
390
+ BasicMessageChannel <Object ?>(
371
391
pigeonVar_channelName,
372
392
pigeonChannelCodec,
373
393
binaryMessenger: pigeonVar_binaryMessenger,
374
394
);
375
- final List <Object ?>? pigeonVar_replyList =
376
- await pigeonVar_channel .send (< Object ? > [options, generalOptions]) as List <Object ?>? ;
395
+ final List <Object ?>? pigeonVar_replyList = await pigeonVar_channel
396
+ .send (< Object ? > [options, generalOptions]) as List <Object ?>? ;
377
397
if (pigeonVar_replyList == null ) {
378
398
throw _createConnectionError (pigeonVar_channelName);
379
399
} else if (pigeonVar_replyList.length > 1 ) {
@@ -396,8 +416,10 @@ class ImagePickerApi {
396
416
///
397
417
/// Returns whether the Photos app was successfully opened.
398
418
Future <bool > openPhotosApp () async {
399
- final String pigeonVar_channelName = 'dev.flutter.pigeon.native_image_picker_macos.ImagePickerApi.openPhotosApp$pigeonVar_messageChannelSuffix ' ;
400
- final BasicMessageChannel <Object ?> pigeonVar_channel = BasicMessageChannel <Object ?>(
419
+ final String pigeonVar_channelName =
420
+ 'dev.flutter.pigeon.native_image_picker_macos.ImagePickerApi.openPhotosApp$pigeonVar_messageChannelSuffix ' ;
421
+ final BasicMessageChannel <Object ?> pigeonVar_channel =
422
+ BasicMessageChannel <Object ?>(
401
423
pigeonVar_channelName,
402
424
pigeonChannelCodec,
403
425
binaryMessenger: pigeonVar_binaryMessenger,
0 commit comments