messages.dart
3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// 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.
import 'package:pigeon/pigeon.dart';
@ConfigurePigeon(PigeonOptions(
dartOut: 'lib/src/messages.g.dart',
dartTestOut: 'test/test_api.g.dart',
javaOut: 'android/src/main/java/io/flutter/plugins/imagepicker/Messages.java',
javaOptions: JavaOptions(
package: 'io.flutter.plugins.imagepicker',
),
copyrightHeader: 'pigeons/copyright.txt',
))
class GeneralOptions {
GeneralOptions(this.allowMultiple, this.usePhotoPicker);
bool allowMultiple;
bool usePhotoPicker;
}
/// Options for image selection and output.
class ImageSelectionOptions {
ImageSelectionOptions({this.maxWidth, this.maxHeight, required this.quality});
/// If set, the max width that the image should be resized to fit in.
double? maxWidth;
/// If set, the max height that the image should be resized to fit in.
double? maxHeight;
/// The quality of the output image, from 0-100.
///
/// 100 indicates original quality.
int quality;
}
class MediaSelectionOptions {
MediaSelectionOptions({
required this.imageSelectionOptions,
});
ImageSelectionOptions imageSelectionOptions;
}
/// Options for image selection and output.
class VideoSelectionOptions {
VideoSelectionOptions({this.maxDurationSeconds});
/// The maximum desired length for the video, in seconds.
int? maxDurationSeconds;
}
// Corresponds to `CameraDevice` from the platform interface package.
enum SourceCamera { rear, front }
// Corresponds to `ImageSource` from the platform interface package.
enum SourceType { camera, gallery }
/// Specification for the source of an image or video selection.
class SourceSpecification {
SourceSpecification(this.type, this.camera);
SourceType type;
SourceCamera? camera;
}
/// An error that occurred during lost result retrieval.
///
/// The data here maps to the `PlatformException` that will be created from it.
class CacheRetrievalError {
CacheRetrievalError({required this.code, this.message});
final String code;
final String? message;
}
// Corresponds to `RetrieveType` from the platform interface package.
enum CacheRetrievalType { image, video }
/// The result of retrieving cached results from a previous run.
class CacheRetrievalResult {
CacheRetrievalResult(
{required this.type, this.error, this.paths = const <String>[]});
/// The type of the retrieved data.
final CacheRetrievalType type;
/// The error from the last selection, if any.
final CacheRetrievalError? error;
/// The results from the last selection, if any.
///
/// Elements must not be null, by convention. See
/// https://github.com/flutter/flutter/issues/97848
final List<String?> paths;
}
@HostApi(dartHostTestHandler: 'TestHostImagePickerApi')
abstract class ImagePickerApi {
/// Selects images and returns their paths.
///
/// Elements must not be null, by convention. See
/// https://github.com/flutter/flutter/issues/97848
@TaskQueue(type: TaskQueueType.serialBackgroundThread)
@async
List<String?> pickImages(
SourceSpecification source,
ImageSelectionOptions options,
GeneralOptions generalOptions,
);
/// Selects video and returns their paths.
///
/// Elements must not be null, by convention. See
/// https://github.com/flutter/flutter/issues/97848
@TaskQueue(type: TaskQueueType.serialBackgroundThread)
@async
List<String?> pickVideos(
SourceSpecification source,
VideoSelectionOptions options,
GeneralOptions generalOptions,
);
/// Selects images and videos and returns their paths.
///
/// Elements must not be null, by convention. See
/// https://github.com/flutter/flutter/issues/97848
@async
List<String?> pickMedia(
MediaSelectionOptions mediaSelectionOptions,
GeneralOptions generalOptions,
);
/// Returns results from a previous app session, if any.
@TaskQueue(type: TaskQueueType.serialBackgroundThread)
CacheRetrievalResult? retrieveLostResults();
}